Skip to content

Commit

Permalink
[NVIDIA] Move Broadcast, Comparison and Concat tests to API 2.0 (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkogteva authored Oct 10, 2023
1 parent 7dc747a commit 11fe56a
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "single_layer_tests/broadcast.hpp"
#include "single_op_tests/broadcast.hpp"

#include <cuda_test_constants.hpp>
#include <vector>

using namespace LayerTestsDefinitions;

namespace {

const std::vector<InferenceEngine::Precision> inputPrecisions = {
InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32, InferenceEngine::Precision::I32};
using namespace ov::test;
using namespace ov::test::utils;

const std::vector<ov::element::Type> input_precisions = {
ov::element::f16, ov::element::f32, ov::element::i32
};

// NUMPY MODE

Expand All @@ -21,39 +23,39 @@ INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast1,
::testing::Combine(::testing::Values(ov::Shape{2, 3, 6}), // target shape
::testing::Values(ov::AxisSet{}), // not used in numpy mode
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::Shape{3, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{3, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast2,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 4, 4}), // target shape
::testing::Values(ov::AxisSet{}), // not used in numpy mode
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::Shape{1, 4, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 4, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast3,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{3, 1, 4}), // target shape
::testing::Values(ov::AxisSet{}), // not used in numpy mode
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::Shape{3, 1, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{3, 1, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast4,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{2, 3, 3, 3, 3, 3, 3, 3}), // target shape
::testing::Values(ov::AxisSet{}), // not used in numpy mode
::testing::Values(ov::op::BroadcastType::NUMPY),
::testing::Values(ov::Shape{1, 3, 1, 3, 1, 3, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 3, 1, 3, 1, 3, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

// BIDIRECTIONAL MODE
Expand All @@ -63,29 +65,29 @@ INSTANTIATE_TEST_CASE_P(smoke_TestBidirectionalBroadcast1,
::testing::Combine(::testing::Values(ov::Shape{2, 1, 4}), // target shape
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{4, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{4, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestBidirectionalBroadcast2,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 4, 4}), // target shape
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{1, 4, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 4, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestBidirectionalBroadcas3,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 1, 2, 2}), // target shape
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{4, 1, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{4, 1, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

// EXPLICIT MODE
Expand All @@ -95,66 +97,65 @@ INSTANTIATE_TEST_CASE_P(smoke_TestExplicitBroadcast1,
::testing::Combine(::testing::Values(ov::Shape{2, 3, 1}), // target shape
::testing::Values(ov::AxisSet{1, 2}), // axes
::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::Values(ov::Shape{3, 1}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{3, 1}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestExplicitBroadcast2,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{5, 3, 7}), // target shape
::testing::Values(ov::AxisSet{0, 2}), // axes
::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::Values(ov::Shape{5, 7}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{5, 7}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_TestExplicitBroadcast3,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{4, 4, 3, 7, 6, 6}), // target shape
::testing::Values(ov::AxisSet{1, 3, 5}), // axes
::testing::Values(ov::op::BroadcastType::EXPLICIT),
::testing::Values(ov::Shape{4, 7, 6}), // input shape
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{4, 7, 6}})), // input shape
::testing::ValuesIn(input_precisions),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

// YOLOv5 operators

const std::vector<InferenceEngine::Precision> precisionsYOLOv5 = {
InferenceEngine::Precision::FP16,
InferenceEngine::Precision::FP32,
const std::vector<ov::element::Type> precisions_YOLOv5 = {
ov::element::f16, ov::element::f32
};

INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest1,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 3, 80, 80, 2}),
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{1, 3, 80, 80, 2}),
::testing::ValuesIn(precisionsYOLOv5),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 3, 80, 80, 2}})),
::testing::ValuesIn(precisions_YOLOv5),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest2,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 3, 40, 40, 2}),
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{1, 3, 40, 40, 2}),
::testing::ValuesIn(precisionsYOLOv5),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 3, 40, 40, 2}})),
::testing::ValuesIn(precisions_YOLOv5),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest3,
BroadcastLayerTest,
::testing::Combine(::testing::Values(ov::Shape{1, 3, 20, 20, 2}),
::testing::Values(ov::AxisSet{}), // not used in bidirectional mode
::testing::Values(ov::op::BroadcastType::BIDIRECTIONAL),
::testing::Values(ov::Shape{1, 3, 20, 20, 2}),
::testing::ValuesIn(precisionsYOLOv5),
::testing::Values(ov::test::utils::DEVICE_NVIDIA)),
::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 3, 20, 20, 2}})),
::testing::ValuesIn(precisions_YOLOv5),
::testing::Values(DEVICE_NVIDIA)),
BroadcastLayerTest::getTestCaseName);

} // namespace
Loading

0 comments on commit 11fe56a

Please sign in to comment.