diff --git a/modules/nvidia_plugin/src/CMakeLists.txt b/modules/nvidia_plugin/src/CMakeLists.txt index 9402ced16..c3e087911 100644 --- a/modules/nvidia_plugin/src/CMakeLists.txt +++ b/modules/nvidia_plugin/src/CMakeLists.txt @@ -63,7 +63,7 @@ target_link_libraries(${OBJ_NAME} fmt-header-only openvino::runtime openvino::runtime::dev - ov_core_dev + openvino::core::dev PRIVATE CUDA::cudart CUDA::cublas diff --git a/modules/nvidia_plugin/src/ops/detection_output.cpp b/modules/nvidia_plugin/src/ops/detection_output.cpp index 22fcdc784..20fff51cd 100644 --- a/modules/nvidia_plugin/src/ops/detection_output.cpp +++ b/modules/nvidia_plugin/src/ops/detection_output.cpp @@ -16,6 +16,11 @@ DetectionOutputOp::DetectionOutputOp(const CreationContext& context, IndexCollection&& inputIds, IndexCollection&& outputIds) : OperationBase{context, node, move(inputIds), move(outputIds)}, element_type_{node.get_input_element_type(0)} { + OPENVINO_ASSERT(node.get_element_type() == element_type_, "Node name: ", GetName()); + for (const auto& input : node.inputs()) { + OPENVINO_ASSERT(input.get_element_type() == element_type_, "Node name: ", GetName()); + } + const auto& ngraph_attrs = node.get_attrs(); kernel::DetectionOutput::Attrs kernel_attrs; diff --git a/modules/nvidia_plugin/src/transformer/cuda_graph_transformer.cpp b/modules/nvidia_plugin/src/transformer/cuda_graph_transformer.cpp index 3f9f3aa75..a54ce2321 100644 --- a/modules/nvidia_plugin/src/transformer/cuda_graph_transformer.cpp +++ b/modules/nvidia_plugin/src/transformer/cuda_graph_transformer.cpp @@ -29,6 +29,7 @@ #include "bidirectional_lstm_sequence_composition.hpp" #include "concat_transformation.hpp" +#include "detection_output_fix_input_types_transformation.hpp" #include "fuse_matmul_add.hpp" #include "matmul_transformations.hpp" #include "reduce_transformation.hpp" @@ -52,6 +53,7 @@ void GraphTransformer::transform(const CUDA::Device& device, if (inference_precision == ov::element::f16 && !isHalfSupported(device)) { inference_precision = ov::element::f32; } + auto upscale_precision = [&]() -> bool { return !isHalfSupported(device) || inference_precision == ov::element::f32; }; @@ -151,6 +153,8 @@ void GraphTransformer::transform(const CUDA::Device& device, pass_manager.register_pass(); pass_manager.register_pass(); pass_manager.register_pass(); + pass_manager.register_pass(); + // Do we actually need to eliminate broadcast one more time at the end? pass_manager.register_pass(); diff --git a/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.cpp b/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.cpp new file mode 100644 index 000000000..b114c59fa --- /dev/null +++ b/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "detection_output_fix_input_types_transformation.hpp" + +#include "openvino/cc/pass/itt.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/detection_output.hpp" +#include "openvino/pass/pattern/op/pattern.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" + +using namespace ov::pass::pattern; + +namespace ov::nvidia_gpu::pass { + +bool detection_output_fix_input_types(Matcher& m) { + const auto d_out = std::dynamic_pointer_cast(m.get_match_root()); + if (!d_out) { + return false; + } + const auto& type = d_out->get_element_type(); + ov::OutputVector inputs; + bool needs_transform = false; + for (std::size_t i = 0; i < d_out->inputs().size(); ++i) { + const auto& input_type = d_out->input(i).get_element_type(); + if (input_type != type) { + needs_transform = true; + const auto convert = std::make_shared(d_out->input_value(i), type); + ov::copy_runtime_info(d_out, convert); + inputs.emplace_back(convert); + } else { + inputs.emplace_back(d_out->input_value(i)); + } + } + if (!needs_transform) { + return false; + } + auto new_d_out = d_out->clone_with_new_inputs(inputs); + new_d_out->set_friendly_name(d_out->get_friendly_name()); + ov::copy_runtime_info(d_out, new_d_out); + ov::replace_node(d_out, new_d_out); + return true; +} + +DetectionOutputFixInputTypesTransformation::DetectionOutputFixInputTypesTransformation() { + MATCHER_SCOPE(DetectionOutputFixInputTypesTransformation); + + const auto d_out = wrap_type(); + matcher_pass_callback callback = [](Matcher& m) { return detection_output_fix_input_types(m); }; + + const auto m = std::make_shared(d_out, matcher_name); + register_matcher(m, callback); +} + +} // namespace ov::nvidia_gpu::pass diff --git a/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.hpp b/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.hpp new file mode 100644 index 000000000..764167bdc --- /dev/null +++ b/modules/nvidia_plugin/src/transformer/detection_output_fix_input_types_transformation.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" + +namespace ov::nvidia_gpu::pass { + +class DetectionOutputFixInputTypesTransformation : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("DetectionOutputFixInputTypesTransformation", "0"); + DetectionOutputFixInputTypesTransformation(); +}; + +} // namespace ov::nvidia_gpu::pass diff --git a/modules/nvidia_plugin/tests/functional/CMakeLists.txt b/modules/nvidia_plugin/tests/functional/CMakeLists.txt index 087070d47..e9860db1a 100644 --- a/modules/nvidia_plugin/tests/functional/CMakeLists.txt +++ b/modules/nvidia_plugin/tests/functional/CMakeLists.txt @@ -24,7 +24,6 @@ ov_add_test_target( openvino_nvidia_gpu_plugin_obj LINK_LIBRARIES openvino::funcSharedTests - gmock INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../include ADD_CLANG_FORMAT diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/behavior/plugin/synthetic.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/behavior/plugin/synthetic.cpp index 144ad535f..3f0ea0dda 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/behavior/plugin/synthetic.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/behavior/plugin/synthetic.cpp @@ -6,8 +6,8 @@ #include #include "behavior/plugin/hetero_synthetic.hpp" -#include "ngraph_functions/builders.hpp" -#include "ngraph_functions/subgraph_builders.hpp" +#include "ov_models/builders.hpp" +#include "ov_models/subgraph_builders.hpp" namespace { using namespace HeteroTests; diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp index 2b461e6d1..e57a0b778 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data.cpp @@ -12,7 +12,7 @@ #include "cuda_test_constants.hpp" #include "finite_comparer.hpp" -#include "ngraph_functions/builders.hpp" +#include "ov_models/builders.hpp" using namespace LayerTestsDefinitions; diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data_add.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data_add.cpp index 2295fa386..9d5ece80c 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data_add.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_backprop_data_add.cpp @@ -10,7 +10,7 @@ #include "cuda_test_constants.hpp" #include "finite_comparer.hpp" -#include "ngraph_functions/builders.hpp" +#include "ov_models/builders.hpp" #include "shared_test_classes/single_layer/convolution_backprop_data.hpp" using namespace LayerTestsDefinitions; diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.cpp index 60c02883a..0cd408b9d 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.hpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.hpp index c5bf77205..83a92fac4 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.hpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convolution_biasadd_activation.hpp @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/cuda_eltwise.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/cuda_eltwise.cpp index 78e62867c..d0e4053fa 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/cuda_eltwise.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/cuda_eltwise.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise_test.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise_test.cpp index b5ec013f4..056ef9f4a 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise_test.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise_test.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp index 05d60ee7c..6f42aa567 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_backprop_data.cpp @@ -12,7 +12,7 @@ #include "cuda_test_constants.hpp" #include "finite_comparer.hpp" -#include "ngraph_functions/builders.hpp" +#include "ov_models/builders.hpp" using namespace LayerTestsDefinitions; diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation.cpp index 70e1228c1..1c36358e9 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation_autogenerated.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation_autogenerated.cpp index 3a8b0258b..7de9bb694 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation_autogenerated.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/group_convolution_biasadd_activation_autogenerated.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/range.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/range.cpp index f4cb18c09..aee55e896 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/range.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/range.cpp @@ -16,7 +16,7 @@ #include #include "kernels/details/cuda_type_traits.hpp" -#include "ngraph_functions/builders.hpp" +#include "ov_models/builders.hpp" namespace { diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/transpose_test.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/transpose_test.cpp index c7f801e6d..3fe94dc13 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/transpose_test.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/transpose_test.cpp @@ -2,42 +2,43 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/transpose.hpp" - -#include #include #include "common_test_utils/test_constants.hpp" +#include "cuda_test_constants.hpp" +#include "single_op_tests/transpose.hpp" -using namespace LayerTestsDefinitions; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32, +using namespace ov::test; +using namespace ov::test::utils; +using ov::test::TransposeLayerTest; + +const std::vector model_types = { + ov::element::f16, + ov::element::f32, }; -const std::vector> inputShapes = { - std::vector{256, 3, 100, 100}, - std::vector{1, 2048, 1, 1}, +const std::vector> input_shapes = { + {{256, 3, 100, 100}}, + {{1, 2048, 1, 1}}, }; -const std::vector> inputOrder = { +const std::vector> input_order = { std::vector{0, 3, 2, 1}, // Empty inputs are currently unsupported in nvidia_gpu. // std::vector{}, }; -const auto params = testing::Combine(testing::ValuesIn(inputOrder), - testing::ValuesIn(netPrecisions), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapes), - testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto params = testing::Combine(testing::ValuesIn(input_order), + testing::ValuesIn(model_types), + testing::ValuesIn(static_shapes_to_test_representation(input_shapes)), + testing::Values(DEVICE_NVIDIA)); -INSTANTIATE_TEST_CASE_P(smoke_Transpose, TransposeLayerTest, params, TransposeLayerTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_Transpose, + TransposeLayerTest, + params, + TransposeLayerTest::getTestCaseName); } // namespace diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/variadic_split.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/variadic_split.cpp index ab3235398..007f41f0a 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/variadic_split.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/variadic_split.cpp @@ -2,24 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/variadic_split.hpp" - #include #include "common_test_utils/test_constants.hpp" #include "cuda_test_constants.hpp" - -using namespace LayerTestsDefinitions; +#include "single_op_tests/variadic_split.hpp" namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, +using namespace ov::test; +using namespace ov::test::utils; +using ov::test::VariadicSplitLayerTest; + +const std::vector model_types = { + ov::element::f32, + ov::element::f16 }; // Sum of elements numSplits = inputShapes[Axis] -const std::vector> smoke_numSplits = { +const std::vector> num_splits = { {1, 16, 5, 8}, {2, 19, 5, 4}, {7, 13, 2, 8}, @@ -27,201 +28,122 @@ const std::vector> smoke_numSplits = { {4, 11, 6, 9}, }; -const std::vector smoke_axis = {-3, -2, -1, 0, 1, 2, 3}; - -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck, - VariadicSplitLayerTest, - ::testing::Combine(::testing::ValuesIn(smoke_numSplits), - ::testing::ValuesIn(smoke_axis), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), - VariadicSplitLayerTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck_U32, - VariadicSplitLayerTest, - ::testing::Combine(::testing::ValuesIn(smoke_numSplits), - ::testing::ValuesIn(smoke_axis), - ::testing::Values(InferenceEngine::Precision::U32), - ::testing::Values(InferenceEngine::Precision::U32), - ::testing::Values(InferenceEngine::Precision::U32), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), - VariadicSplitLayerTest::getTestCaseName); +const std::vector axis = {-3, -2, -1, 0, 1, 2, 3}; -INSTANTIATE_TEST_CASE_P(smoke_NumSplitsCheck_I64, +INSTANTIATE_TEST_CASE_P(num_splitsCheck, VariadicSplitLayerTest, - ::testing::Combine(::testing::ValuesIn(smoke_numSplits), - ::testing::ValuesIn(smoke_axis), - ::testing::Values(InferenceEngine::Precision::I64), - ::testing::Values(InferenceEngine::Precision::I64), - ::testing::Values(InferenceEngine::Precision::I64), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({30, 30, 30, 30})), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::Combine(::testing::ValuesIn(num_splits), + ::testing::ValuesIn(axis), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{30, 30, 30, 30}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape0_axis1, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{1, 1, 1}), ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 40, 40, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 40, 40, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape0_axis2, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{10, 20, 10}), ::testing::Values(2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 40, 40, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 40, 40, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape0_axis3, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{5, 5, 30}), ::testing::Values(3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 40, 40, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 40, 40, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape0_axis4, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{20, 60, 5}), ::testing::Values(4), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 40, 40, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 40, 40, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape1_axis1, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{1, 1, 1}), ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 20, 20, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 20, 20, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape1_axis2, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{5, 12, 3}), ::testing::Values(2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 20, 20, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 20, 20, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape1_axis3, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{2, 8, 10}), ::testing::Values(3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 20, 20, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 20, 20, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape1_axis4, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{65, 3, 17}), ::testing::Values(4), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 20, 20, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 20, 20, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape2_axis1, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{1, 1, 1}), ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 80, 80, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 80, 80, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape2_axis2, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{13, 13, 54}), ::testing::Values(2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 80, 80, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 80, 80, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape2_axis3, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{7, 3, 70}), ::testing::Values(3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 80, 80, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 80, 80, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(yolov5_NumSplitsCheck_shape2_axis4, VariadicSplitLayerTest, ::testing::Combine(::testing::Values(std::vector{1, 1, 83}), ::testing::Values(4), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 3, 80, 80, 85}), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(model_types), + ::testing::Values(static_shapes_to_test_representation({{1, 3, 80, 80, 85}})), + ::testing::Values(DEVICE_NVIDIA)), VariadicSplitLayerTest::getTestCaseName); - } // namespace diff --git a/modules/nvidia_plugin/tests/unit/CMakeLists.txt b/modules/nvidia_plugin/tests/unit/CMakeLists.txt index 5782a061c..7d06bf257 100644 --- a/modules/nvidia_plugin/tests/unit/CMakeLists.txt +++ b/modules/nvidia_plugin/tests/unit/CMakeLists.txt @@ -32,11 +32,11 @@ ov_add_test_target( EXCLUDED_SOURCE_PATHS ${EXCLUDED_SOURCE_PATHS} LINK_LIBRARIES - gtest - gtest_main - gmock - ngraphFunctions - commonTestUtils + openvino::gtest + openvino::gtest_main + openvino::gmock + openvino::ov_models + openvino::commonTestUtils ADD_CPPLINT ADD_CLANG_FORMAT LABELS diff --git a/modules/nvidia_plugin/tests/unit/cuda_multi_graph_test.cpp b/modules/nvidia_plugin/tests/unit/cuda_multi_graph_test.cpp index f4e4a0cf7..0ac6151f1 100644 --- a/modules/nvidia_plugin/tests/unit/cuda_multi_graph_test.cpp +++ b/modules/nvidia_plugin/tests/unit/cuda_multi_graph_test.cpp @@ -6,8 +6,8 @@ #include "cuda_graph_topology_runner.hpp" #include "cuda_simple_execution_delegator.hpp" -#include "ngraph_functions/builders.hpp" -#include "ngraph_functions/utils/data_utils.hpp" +#include "ov_models/builders.hpp" +#include "ov_models/utils/data_utils.hpp" #include "ops/parameter.hpp" #include "ops/result.hpp" diff --git a/modules/nvidia_plugin/tests/unit/transformations/detection_output_fix_input_types.cpp b/modules/nvidia_plugin/tests/unit/transformations/detection_output_fix_input_types.cpp new file mode 100644 index 000000000..2074575ec --- /dev/null +++ b/modules/nvidia_plugin/tests/unit/transformations/detection_output_fix_input_types.cpp @@ -0,0 +1,148 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "cuda_operation_registry.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/detection_output.hpp" +#include "openvino/pass/manager.hpp" +#include "transformations/init_node_info.hpp" +#include "transformer/detection_output_fix_input_types_transformation.hpp" + +using namespace ov; + +namespace { + +op::v0::DetectionOutput::Attributes get_attrs() { + op::v0::DetectionOutput::Attributes attrs; + + attrs.background_label_id = 12; + attrs.top_k = 75; + attrs.variance_encoded_in_target = true; + attrs.keep_top_k = {50}; + attrs.code_type = "caffe.PriorBoxParameter.CORNER"; + attrs.share_location = true; + attrs.nms_threshold = 0.5f; + attrs.confidence_threshold = 0.3f; + attrs.clip_after_nms = true; + attrs.clip_before_nms = true; + attrs.decrease_label_id = true; + attrs.normalized = true; + attrs.input_height = 1ul; + attrs.input_width = 1ul; + attrs.objectness_score = 0.4f; + attrs.num_classes = 11; + + return attrs; +} + +ov::nvidia_gpu::OperationBase::Ptr createPluginOperation(const std::shared_ptr& node) { + return ov::nvidia_gpu::OperationRegistry::getInstance().createOperation( + ov::nvidia_gpu::CreationContext{CUDA::Device{}, false}, + node, + std::vector{ov::nvidia_gpu::TensorID{0u}}, + std::vector{ov::nvidia_gpu::TensorID{0u}}); +} + +template +std::shared_ptr find_op(const std::shared_ptr model) { + for (const auto& node : model->get_ordered_ops()) { + if (const auto op = std::dynamic_pointer_cast(node)) { + return op; + } + } + return nullptr; +} + +} // namespace + +namespace testing { + +TEST(detection_output_fix_input_types, three_params) { + // Proposals type is different + const ParameterVector param_vec{std::make_shared(element::Type_t::f16, Shape{1, 60}), + std::make_shared(element::Type_t::f16, Shape{1, 165}), + std::make_shared(element::Type_t::f32, Shape{1, 1, 60})}; + + std::shared_ptr model, model_ref; + { + const auto d_out = + std::make_shared(param_vec[0], param_vec[1], param_vec[2], get_attrs()); + ASSERT_THROW(createPluginOperation(d_out), ov::AssertFailure); + + model = std::make_shared(d_out, param_vec); + + pass::Manager pass_manager; + pass_manager.register_pass(); + pass_manager.register_pass(); + pass_manager.run_passes(model); + + ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(model->get_results()[0]->input(0).get_element_type(), element::f16); + + const auto new_d_out = find_op(model); + ASSERT_NE(new_d_out, nullptr); + ASSERT_NO_THROW(createPluginOperation(new_d_out)); + } + { + const auto convert = std::make_shared(param_vec[2], element::Type_t::f16); + + const auto d_out = std::make_shared(param_vec[0], param_vec[1], convert, get_attrs()); + ASSERT_NO_THROW(createPluginOperation(d_out)); + + model_ref = std::make_shared(d_out, param_vec); + ASSERT_EQ(count_ops_of_type(model), 1); + } + const auto res = FunctionsComparator::with_default().compare(model, model_ref); + ASSERT_TRUE(res.valid) << res.message; +} + +TEST(detection_output_fix_input_types, five_params) { + // Proposals type is different + const ParameterVector param_vec{std::make_shared(element::Type_t::f32, Shape{1, 60}), + std::make_shared(element::Type_t::f32, Shape{1, 165}), + std::make_shared(element::Type_t::f16, Shape{1, 1, 60}), + std::make_shared(element::Type_t::f32, Shape{1, 30}), + std::make_shared(element::Type_t::f32, Shape{1, 60})}; + + std::shared_ptr model, model_ref; + { + const auto d_out = std::make_shared( + param_vec[0], param_vec[1], param_vec[2], param_vec[3], param_vec[4], get_attrs()); + ASSERT_THROW(createPluginOperation(d_out), ov::AssertFailure); + + model = std::make_shared(d_out, param_vec); + + pass::Manager pass_manager; + pass_manager.register_pass(); + pass_manager.register_pass(); + pass_manager.run_passes(model); + + ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(model->get_results()[0]->input(0).get_element_type(), element::f32); + + const auto new_d_out = find_op(model); + ASSERT_NE(new_d_out, nullptr); + ASSERT_NO_THROW(createPluginOperation(new_d_out)); + } + { + const auto convert = std::make_shared(param_vec[2], element::Type_t::f32); + + const auto d_out = std::make_shared( + param_vec[0], param_vec[1], convert, param_vec[3], param_vec[4], get_attrs()); + ASSERT_NO_THROW(createPluginOperation(d_out)); + + model_ref = std::make_shared(d_out, param_vec); + ASSERT_EQ(count_ops_of_type(model), 1); + } + const auto res = FunctionsComparator::with_default().compare(model, model_ref); + ASSERT_TRUE(res.valid) << res.message; +} + +} // namespace testing