From 4150a62fa37b062e2772435576f32221a3f71c48 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 9 Oct 2023 11:22:23 +0300 Subject: [PATCH 1/7] Hide custom operator overloading since them are already supported in CUDA 12 (#740) Co-authored-by: Denis Kotov --- modules/nvidia_plugin/src/cuda/float16.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nvidia_plugin/src/cuda/float16.hpp b/modules/nvidia_plugin/src/cuda/float16.hpp index 44f6c6360..ad0774ee4 100644 --- a/modules/nvidia_plugin/src/cuda/float16.hpp +++ b/modules/nvidia_plugin/src/cuda/float16.hpp @@ -20,7 +20,7 @@ #define CUDA_HAS_BF16_MATH #endif // defined (CUDA_HAS_BF16_TYPE) && (__CUDA_ARCH__ >= 800 || !defined(__CUDA_ARCH__)) -#ifdef __CUDACC__ +#if defined(__CUDACC__) && CUDA_VERSION < 12000 #if !defined(CUDA_HAS_HALF_MATH) /* Some basic arithmetic operations expected of a builtin */ __device__ __forceinline__ __half operator+(const __half &lh, const __half &rh) { @@ -192,4 +192,4 @@ __device__ __forceinline__ bool operator<=(const __nv_bfloat16 &lh, const __nv_b return static_cast(lh) <= static_cast(rh); } #endif /* defined(CUDA_HAS_BF16_TYPE) && !defined(CUDA_HAS_BF16_MATH) */ -#endif // __CUDACC__ +#endif // defined(__CUDACC__) && CUDA_VERSION < 12000 From 000bb22df057ab1b977ec4e569a75944a2d20d6b Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 9 Oct 2023 11:34:57 +0300 Subject: [PATCH 2/7] [NVIDIA] Add additional paths for cuTensor library (#739) * Add additional paths for cuTensor library that should be observed * Changed -> CUDAToolkit_VERSION_MAJOR --------- Co-authored-by: Denis Kotov --- modules/nvidia_plugin/CMakeLists.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/nvidia_plugin/CMakeLists.txt b/modules/nvidia_plugin/CMakeLists.txt index ab375affa..b05fbadb1 100644 --- a/modules/nvidia_plugin/CMakeLists.txt +++ b/modules/nvidia_plugin/CMakeLists.txt @@ -92,14 +92,23 @@ endif() find_library(CUDNN_PATH NAMES cudnn ${HAS_REQUIRED} - HINTS "$ENV{CUDNN_PATH}" "${CUDA_TOOLKIT_ROOT_DIR}" "${CUDA_PATH}" "$ENV{CUDA_PATH}" + HINTS "$ENV{CUDNN_PATH}" "${CUDA_TOOLKIT_ROOT_DIR}" "${CUDA_PATH}" "$ENV{CUDA_PATH}" PATH_SUFFIXES nvidia/current lib64 lib/x64 lib) +if(CUDAToolkit_VERSION_MAJOR LESS_EQUAL 10) + set(CUTENSOR_LIB_DIRS lib/10.2 libcutensor/10.2) +elseif(CUDAToolkit_VERSION_MAJOR GREATER_EQUAL 11 AND CUDAToolkit_VERSION_MINOR LESS_EQUAL 0) + set(CUTENSOR_LIB_DIRS lib/11.0 libcutensor/11.0) +elseif(CUDAToolkit_VERSION_MAJOR GREATER_EQUAL 11 AND CUDAToolkit_VERSION_MINOR GREATER_EQUAL 1) + set(CUTENSOR_LIB_DIRS lib/11 libcutensor/11) +else() + set(CUTENSOR_LIB_DIRS lib/${CUDAToolkit_VERSION_MAJOR} libcutensor/${CUDAToolkit_VERSION_MAJOR}) +endif() find_library(CUTENSOR_PATH NAMES cutensor ${HAS_REQUIRED} HINTS "$ENV{CUTENSOR_PATH}" "${CUDA_TOOLKIT_ROOT_DIR}" "${CUDA_PATH}" "$ENV{CUDA_PATH}" - PATH_SUFFIXES nvidia/current lib64 lib/x64 lib lib/11) + PATH_SUFFIXES nvidia/current lib64 lib/x64 lib ${CUTENSOR_LIB_DIRS}) get_filename_component(CUTENSOR_INCLUDE_DIR "${CUTENSOR_PATH}" DIRECTORY) get_filename_component(CUTENSOR_INCLUDE_DIR "${CUTENSOR_INCLUDE_DIR}/../../include" REALPATH) @@ -121,11 +130,11 @@ set_target_properties(CUDA::cutensor PROPERTIES IMPORTED_LOCATION "${CUTENSOR_PA set_target_properties(CUDA::cutensor PROPERTIES IMPORTED_IMPLIB "${CUTENSOR_PATH}") if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - if(${CUDAToolkit_VERSION_MAJOR} LESS_EQUAL 10) + if(CUDAToolkit_VERSION_MAJOR LESS_EQUAL 10) set(CMAKE_CUDA_ARCHITECTURES "30;35;50;60;72") - elseif(${CUDAToolkit_VERSION_MAJOR} EQUAL 11 AND ${CUDAToolkit_VERSION_MINOR} LESS_EQUAL 7) + elseif(CUDAToolkit_VERSION_MAJOR EQUAL 11 AND CUDAToolkit_VERSION_MINOR LESS_EQUAL 7) set(CMAKE_CUDA_ARCHITECTURES "35;50;60-virtual;61;70-virtual;75;86") - elseif(${CUDAToolkit_VERSION_MAJOR} EQUAL 11 AND ${CUDAToolkit_VERSION_MINOR} EQUAL 8) + elseif(CUDAToolkit_VERSION_MAJOR EQUAL 11 AND CUDAToolkit_VERSION_MINOR EQUAL 8) set(CMAKE_CUDA_ARCHITECTURES "35;50;60-virtual;61;70-virtual;75;86;89-virtual;90-virtual") else() set(CMAKE_CUDA_ARCHITECTURES "50;60-virtual;61;70-virtual;75;86;89-virtual;90-virtual") From 15a840f9655a47afccffa5ef6756d3fb7f680a95 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 10 Oct 2023 11:31:43 +0400 Subject: [PATCH 3/7] Fixed compilation when building out of OV source tree (#744) --- modules/nvidia_plugin/CMakeLists.txt | 12 +++++------- modules/nvidia_plugin/src/CMakeLists.txt | 4 ++-- .../nvidia_plugin/tests/functional/CMakeLists.txt | 9 +++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/nvidia_plugin/CMakeLists.txt b/modules/nvidia_plugin/CMakeLists.txt index b05fbadb1..4a40aee55 100644 --- a/modules/nvidia_plugin/CMakeLists.txt +++ b/modules/nvidia_plugin/CMakeLists.txt @@ -3,7 +3,7 @@ # cmake_minimum_required(VERSION 3.13) -project(InferenceEngineNVIDIAGpuPlugin CXX CUDA) +project(OpenVINONVIDIAGpuPlugin CXX CUDA) # Initialize CMAKE_CUDA_ARCHITECTURES when CMAKE_CUDA_COMPILER_ID is NVIDIA. # Raise an error if CUDA_ARCHITECTURES is empty. @@ -26,8 +26,6 @@ if (ENABLE_CUDNN_BACKEND_API) add_definitions(-DENABLE_CUDNN_BACKEND_API) endif() -set(IE_MAIN_CUDA_PLUGIN_SOURCE_DIR ${InferenceEngineNVIDIAGpuPlugin_SOURCE_DIR}) - find_package(OpenVINODeveloperPackage REQUIRED PATHS "${InferenceEngineDeveloperPackage_DIR}") @@ -35,7 +33,7 @@ include(cmake/features.cmake) set(HAS_REQUIRED REQUIRED) -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(CMAKE_VERSION VERSION_LESS 3.17.0) set(HAS_REQUIRED) find_package(CUDA REQUIRED) set(CUDAToolkit_VERSION_MAJOR ${CUDA_VERSION_MAJOR}) @@ -149,7 +147,7 @@ include(FetchContent) FetchContent_Declare(GSL GIT_REPOSITORY "https://github.com/microsoft/GSL" GIT_TAG "v3.1.0") -if(${CMAKE_VERSION} VERSION_LESS "3.14.0") +if(CMAKE_VERSION VERSION_LESS 3.14.0) FetchContent_GetProperties(GSL) if(NOT GSL_POPULATED) FetchContent_Populate(GSL) @@ -165,7 +163,7 @@ set_property(TARGET GSL PROPERTY INTERFACE_COMPILE_FEATURES) FetchContent_Declare(fmt-header-only GIT_REPOSITORY "https://github.com/fmtlib/fmt" GIT_TAG "7.1.3") -if(${CMAKE_VERSION} VERSION_LESS "3.14.0") +if(CMAKE_VERSION VERSION_LESS 3.14.0) FetchContent_GetProperties(fmt-header-only) if(NOT fmt-header-only_POPULATED) FetchContent_Populate(fmt-header-only) @@ -194,4 +192,4 @@ endif() # install # ATTENTION: uncomment to install component -# ie_cpack(template) +# ov_cpack(template) diff --git a/modules/nvidia_plugin/src/CMakeLists.txt b/modules/nvidia_plugin/src/CMakeLists.txt index c3e087911..e95f98e4e 100644 --- a/modules/nvidia_plugin/src/CMakeLists.txt +++ b/modules/nvidia_plugin/src/CMakeLists.txt @@ -43,7 +43,7 @@ ov_mark_target_as_cc(${TARGET_NAME}) set_property(TARGET ${OBJ_NAME} PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) -ieTargetLinkWholeArchive(${TARGET_NAME} ${OBJ_NAME}) +ov_target_link_whole_archive(${TARGET_NAME} ${OBJ_NAME}) target_include_directories(${OBJ_NAME} SYSTEM PUBLIC @@ -53,7 +53,7 @@ target_include_directories(${OBJ_NAME} PUBLIC "${CUTENSOR_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" - "${IE_MAIN_CUDA_PLUGIN_SOURCE_DIR}/include" + "${OpenVINONVIDIAGpuPlugin_SOURCE_DIR}/include" PRIVATE $ ) diff --git a/modules/nvidia_plugin/tests/functional/CMakeLists.txt b/modules/nvidia_plugin/tests/functional/CMakeLists.txt index e9860db1a..0c116a594 100644 --- a/modules/nvidia_plugin/tests/functional/CMakeLists.txt +++ b/modules/nvidia_plugin/tests/functional/CMakeLists.txt @@ -3,14 +3,12 @@ # SPDX-License-Identifier: Apache-2.0 # -# [cmake:functional_tests] set(TARGET_NAME ov_nvidia_func_tests) -if (ENABLE_INTEL_CPU) +# TODO: remove dependency on CPU plugin after migration to tests for API 2.0 +if(CMAKE_SOURCE_DIR STREQUAL OpenVINO_SOURCE_DIR AND ENABLE_INTEL_CPU) set(OPENVINO_ADDITIONAL_DEPENDENCIES openvino_intel_cpu_plugin) -else(ENABLE_INTEL_CPU) - set(OPENVINO_ADDITIONAL_DEPENDENCIES) -endif (ENABLE_INTEL_CPU) +endif() ov_add_test_target( NAME @@ -34,4 +32,3 @@ ov_add_test_target( if(ENABLE_PROXY) target_compile_definitions(${TARGET_NAME} PUBLIC PROXY_PLUGIN_ENABLED) endif() -# [cmake:functional_tests] From 7dc747aed4c2ca0f801da92cccace9cebf7187a5 Mon Sep 17 00:00:00 2001 From: Nadezhda Ageeva Date: Tue, 10 Oct 2023 11:58:23 +0400 Subject: [PATCH 4/7] [NVIDIA] Move Logical layer test to API 2.0 (#738) --- .../single_layer_tests/logical_test.cpp | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/logical_test.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/logical_test.cpp index 7bcbf3f67..5bf311c69 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/logical_test.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/logical_test.cpp @@ -1,16 +1,17 @@ // Copyright (C) 2021-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include #include -using namespace LayerTestsDefinitions; -using namespace LayerTestsDefinitions::LogicalParams; - +#include "cuda_test_constants.hpp" +#include "single_op_tests/logical.hpp" namespace { -std::map, std::vector>> inputShapesNot = { +using namespace ov::test; +using namespace ov::test::utils; +using ov::test::LogicalLayerTest; + +std::map> input_shapes_not = { {{256}, {}}, {{50, 200}, {}}, {{1, 3, 20}, {}}, @@ -18,28 +19,37 @@ std::map, std::vector>> inputShapesNot = {{2, 3, 25, 4, 13}, {}}, }; -std::vector inputsPrecisions = { - InferenceEngine::Precision::BOOL, -}; - -std::vector netPrecisions = { - InferenceEngine::Precision::BOOL, +std::vector model_types = { + ov::element::boolean, }; std::map additional_config = {}; +std::vector> combine_shapes(const std::map>& input_shapes_static) { + std::vector> result; + for (const auto& input_shape : input_shapes_static) { + for (auto& item : input_shape.second) { + result.push_back({input_shape.first, item}); + } + + if (input_shape.second.empty()) { + result.push_back({input_shape.first, {}}); + } + } + return result; +} + const auto LogicalTestParamsNot = - ::testing::Combine(::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapesNot)), - ::testing::Values(ngraph::helpers::LogicalTypes::LOGICAL_NOT), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputsPrecisions), - ::testing::Values(InferenceEngine::Precision::BOOL), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA), + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(combine_shapes(input_shapes_not))), + ::testing::Values(LogicalTypes::LOGICAL_NOT), + ::testing::Values(InputLayerType::CONSTANT), + ::testing::ValuesIn(model_types), + ::testing::Values(DEVICE_NVIDIA), ::testing::Values(additional_config)); -INSTANTIATE_TEST_CASE_P(smoke_LogicalNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_LogicalNot, + LogicalLayerTest, + LogicalTestParamsNot, + LogicalLayerTest::getTestCaseName); } // namespace From 11fe56a9cbcc828d4e262e106bfdabe5ed6803e7 Mon Sep 17 00:00:00 2001 From: Nadezhda Ageeva Date: Tue, 10 Oct 2023 16:13:33 +0400 Subject: [PATCH 5/7] [NVIDIA] Move Broadcast, Comparison and Concat tests to API 2.0 (#734) --- .../single_layer_tests/broadcast.cpp | 95 +++++++-------- .../single_layer_tests/comparison.cpp | 107 ++++++++-------- .../single_layer_tests/concat.cpp | 23 ++-- .../single_layer_tests/ov_benchmark.hpp | 114 ++++++++++++++++++ .../ov_unsymmetrical_comparer.hpp | 35 ++++++ 5 files changed, 262 insertions(+), 112 deletions(-) create mode 100644 modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_benchmark.hpp create mode 100644 modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_unsymmetrical_comparer.hpp diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp index 5503590b8..b8ff4b2ed 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp @@ -2,17 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/broadcast.hpp" +#include "single_op_tests/broadcast.hpp" #include #include -using namespace LayerTestsDefinitions; - namespace { -const std::vector inputPrecisions = { - InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32, InferenceEngine::Precision::I32}; +using namespace ov::test; +using namespace ov::test::utils; + +const std::vector input_precisions = { + ov::element::f16, ov::element::f32, ov::element::i32 +}; // NUMPY MODE @@ -21,9 +23,9 @@ 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, @@ -31,9 +33,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast2, ::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, @@ -41,9 +43,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast3, ::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, @@ -51,9 +53,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast4, ::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 @@ -63,9 +65,9 @@ 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, @@ -73,9 +75,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestBidirectionalBroadcast2, ::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, @@ -83,9 +85,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestBidirectionalBroadcas3, ::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 @@ -95,9 +97,9 @@ 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, @@ -105,9 +107,9 @@ INSTANTIATE_TEST_CASE_P(smoke_TestExplicitBroadcast2, ::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, @@ -115,16 +117,15 @@ INSTANTIATE_TEST_CASE_P(smoke_TestExplicitBroadcast3, ::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 precisionsYOLOv5 = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32, +const std::vector precisions_YOLOv5 = { + ov::element::f16, ov::element::f32 }; INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest1, @@ -132,9 +133,9 @@ INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest1, ::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, @@ -142,9 +143,9 @@ INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest2, ::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, @@ -152,9 +153,9 @@ INSTANTIATE_TEST_CASE_P(yolov5_BroadcastTest3, ::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 diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp index 29fd1370b..39a972fb2 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp @@ -2,27 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/comparison.hpp" +#include "shared_test_classes/single_op/comparison.hpp" #include -#include "common_test_utils/test_constants.hpp" #include "cuda_test_constants.hpp" -#include "unsymmetrical_comparer.hpp" - -using namespace LayerTestsDefinitions; -using namespace LayerTestsDefinitions::ComparisonParams; - -namespace LayerTestsDefinitions { +#include "functional_test_utils/skip_tests_config.hpp" +#include "ov_unsymmetrical_comparer.hpp" +namespace { +using namespace ov::test; +using namespace ov::test::utils; +using namespace ngraph::helpers; class UnsymmetricalComparisonLayerTest : public UnsymmetricalComparer {}; -TEST_P(UnsymmetricalComparisonLayerTest, CompareWithRefs) { Run(); } -} // namespace LayerTestsDefinitions +TEST_P(UnsymmetricalComparisonLayerTest, Inference) { run(); } -namespace { - -std::map, std::vector>> smokeShapes = { +std::map> smoke_shapes = { {{1}, {{1}, {17}, {1, 1}, {2, 18}, {1, 1, 2}, {2, 2, 3}, {1, 1, 2, 3}}}, {{5}, {{1}, {1, 1}, {2, 5}, {1, 1, 1}, {2, 2, 5}}}, {{2, 200}, {{1}, {200}, {1, 200}, {2, 200}, {2, 2, 200}}}, @@ -30,79 +26,86 @@ std::map, std::vector>> smokeShapes = { {{2, 17, 3, 4}, {{4}, {1, 3, 4}, {2, 1, 3, 4}}}, {{2, 1, 1, 3, 1}, {{1}, {1, 3, 4}, {2, 1, 3, 4}, {1, 1, 1, 1, 1}}}, }; +auto converter = [] (const std::vector>& shapes) { + std::vector> result; + for (const auto& shape : shapes) { + result.push_back({shape.first, shape.second}); + } + return result; +}; +auto input_smoke_shapes_pair_vector = ov::test::utils::combineParams(smoke_shapes); +auto input_smoke_shapes_static = converter(input_smoke_shapes_pair_vector); -std::map, std::vector>> shapes = { +std::map> shapes = { {{1}, {{256}}}, }; +auto input_shapes_pair_vector = ov::test::utils::combineParams(shapes); +auto input_shapes_static = converter(input_shapes_pair_vector); -std::vector inputsPrecisions = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32, +std::vector model_type = { + ov::element::f32, + ov::element::f16, }; -std::vector comparisonOpTypes = { - ngraph::helpers::ComparisonTypes::EQUAL, - ngraph::helpers::ComparisonTypes::NOT_EQUAL, - ngraph::helpers::ComparisonTypes::GREATER, - ngraph::helpers::ComparisonTypes::GREATER_EQUAL, - ngraph::helpers::ComparisonTypes::LESS, - ngraph::helpers::ComparisonTypes::LESS_EQUAL, +std::vector comparison_op_types = { + ComparisonTypes::EQUAL, + ComparisonTypes::NOT_EQUAL, + ComparisonTypes::GREATER, + ComparisonTypes::GREATER_EQUAL, + ComparisonTypes::LESS, + ComparisonTypes::LESS_EQUAL, }; -std::vector secondInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER, +std::vector second_input_types = { + InputLayerType::CONSTANT, + InputLayerType::PARAMETER, }; std::map additional_config = {}; -const auto smokeComparisonTestParams = - ::testing::Combine(::testing::ValuesIn(ov::test::utils::combineParams(smokeShapes)), - ::testing::ValuesIn(inputsPrecisions), - ::testing::ValuesIn(comparisonOpTypes), - ::testing::ValuesIn(secondInputTypes), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA), +const auto smoke_comparison_test_params = + ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_smoke_shapes_static)), + ::testing::ValuesIn(comparison_op_types), + ::testing::ValuesIn(second_input_types), + ::testing::ValuesIn(model_type), + ::testing::Values(DEVICE_NVIDIA), ::testing::Values(additional_config)); -const auto comparisonTestParams = ::testing::Combine(::testing::ValuesIn(ov::test::utils::combineParams(shapes)), - ::testing::ValuesIn(inputsPrecisions), - ::testing::ValuesIn(comparisonOpTypes), - ::testing::ValuesIn(secondInputTypes), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA), - ::testing::Values(additional_config)); +const auto comparison_test_params = ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), + ::testing::ValuesIn(comparison_op_types), + ::testing::ValuesIn(second_input_types), + ::testing::ValuesIn(model_type), + ::testing::Values(DEVICE_NVIDIA), + ::testing::Values(additional_config)); INSTANTIATE_TEST_CASE_P(smoke_ComparisonCompareWithRefs, UnsymmetricalComparisonLayerTest, - smokeComparisonTestParams, + smoke_comparison_test_params, ComparisonLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(ComparisonCompareWithRefs, UnsymmetricalComparisonLayerTest, - comparisonTestParams, + comparison_test_params, ComparisonLayerTest::getTestCaseName); +} // namespace + // ------------- Benchmark ------------- -#include "benchmark.hpp" +#include "ov_benchmark.hpp" -namespace LayerTestsDefinitions { +namespace { namespace benchmark { struct ComparisonBenchmarkTest : BenchmarkLayerTest {}; TEST_P(ComparisonBenchmarkTest, DISABLED_benchmark) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Run("Comparison", std::chrono::milliseconds(2000), 100); + run("Comparison", std::chrono::milliseconds(2000), 100); } INSTANTIATE_TEST_CASE_P(smoke_ComparisonCompareWithRefs, ComparisonBenchmarkTest, - smokeComparisonTestParams, + smoke_comparison_test_params, ComparisonLayerTest::getTestCaseName); } // namespace benchmark - -} // namespace LayerTestsDefinitions -} // namespace +} // namespace \ No newline at end of file diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/concat.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/concat.cpp index e6568ce69..7b708753f 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/concat.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/concat.cpp @@ -2,38 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/concat.hpp" +#include "single_op_tests/concat.hpp" #include #include "common_test_utils/test_constants.hpp" #include "cuda_test_constants.hpp" -using namespace LayerTestsDefinitions; - namespace { +using namespace ov::test; +using namespace ov::test::utils; + std::vector axes = {-3, -2, -1, 0, 1, 2, 3}; -std::vector>> inShapes = { +std::vector> shapes_static = { {{10, 10, 10, 10}}, {{10, 10, 10, 10}, {10, 10, 10, 10}}, {{10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}}, {{10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}}, {{10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}, {10, 10, 10, 10}}}; -std::vector netPrecisions = {InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16}; +std::vector model_precisions = {ov::element::f32, + ov::element::f16}; INSTANTIATE_TEST_CASE_P(smoke_NoReshape, ConcatLayerTest, ::testing::Combine(::testing::ValuesIn(axes), - ::testing::ValuesIn(inShapes), - ::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(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(static_shapes_to_test_representation(shapes_static)), + ::testing::ValuesIn(model_precisions), + ::testing::Values(DEVICE_NVIDIA)), ConcatLayerTest::getTestCaseName); } // namespace diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_benchmark.hpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_benchmark.hpp new file mode 100644 index 000000000..8b5518562 --- /dev/null +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_benchmark.hpp @@ -0,0 +1,114 @@ +// Copyright (C) 2021-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "openvino/runtime/properties.hpp" + +namespace ov { +namespace test { + +template +class BenchmarkLayerTest : public BaseLayerTest { + static_assert(std::is_base_of::value, + "BaseLayerTest should inherit from ov::test::SubgraphBaseTest"); + +public: + void run(const std::initializer_list& names, + const std::chrono::milliseconds warmupTime = std::chrono::milliseconds(2000), + const int numAttempts = 100) { + bench_names_ = names; + warmup_time_ = warmupTime; + num_attempts_ = numAttempts; + SubgraphBaseTest::configuration = {ov::enable_profiling(true)}; + SubgraphBaseTest::run(); + } + + void run(const std::string& name, + const std::chrono::milliseconds warmupTime = std::chrono::milliseconds(2000), + const int numAttempts = 100) { + if (!name.empty()) { + run({name}, warmupTime, numAttempts); + } else { + run({}, warmupTime, numAttempts); + } + } + + void validate() override { + // NOTE: Validation is ignored because we are interested in benchmarks results + } + +protected: + void infer() override { + // Operation names search + std::map results_us{}; + SubgraphBaseTest::infer(); + const auto& perf_results = SubgraphBaseTest::inferRequest.get_profiling_info(); + for (const auto& name : bench_names_) { + bool found = false; + for (const auto& result : perf_results) { + const auto& res_name = result.node_name; + const bool should_add = + !name.empty() && res_name.find(name) != std::string::npos && res_name.find('_') != std::string::npos; + // Adding operations with numbers for the case there are several operations of the same type + if (should_add) { + found = true; + results_us.emplace(std::make_pair(res_name, std::chrono::microseconds::zero())); + } + } + if (!found) { + std::cout << "WARNING! Performance count for \"" << name << "\" wasn't found!\n"; + } + } + // If no operations were found adding the time of all operations except Parameter and Result + if (results_us.empty()) { + for (const auto& result : perf_results) { + const auto& res_name = result.node_name; + const bool should_add = (res_name.find("Parameter") == std::string::npos) && + (res_name.find("Result") == std::string::npos) && + (res_name.find('_') != std::string::npos); + if (should_add) { + results_us.emplace(std::make_pair(res_name, std::chrono::microseconds::zero())); + } + } + } + // Warmup + auto warmCur = std::chrono::steady_clock::now(); + const auto warmEnd = warmCur + warmup_time_; + while (warmCur < warmEnd) { + SubgraphBaseTest::infer(); + warmCur = std::chrono::steady_clock::now(); + } + // Benchmark + for (int i = 0; i < num_attempts_; ++i) { + SubgraphBaseTest::infer(); + const auto& perf_results = SubgraphBaseTest::inferRequest.get_profiling_info(); + for (auto& [name, time] : results_us) { + auto it = std::find_if(perf_results.begin(), perf_results.end(), [&](const ::ov::ProfilingInfo& info) { return info.node_name == name; }); + OPENVINO_ASSERT(it != perf_results.end()); + time += it->real_time; + } + } + + std::chrono::microseconds total_us = std::chrono::microseconds::zero(); + for (auto& [name, time] : results_us) { + time /= num_attempts_; + total_us += time; + std::cout << std::fixed << std::setfill('0') << name << ": " << time.count() << " us\n"; + } + std::cout << std::fixed << std::setfill('0') << "Total time: " << total_us.count() << " us\n"; + } + +private: + std::vector bench_names_; + std::chrono::milliseconds warmup_time_; + int num_attempts_; +}; + +} // namespace test +} // namespace ov diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_unsymmetrical_comparer.hpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_unsymmetrical_comparer.hpp new file mode 100644 index 000000000..6ac83dc81 --- /dev/null +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/ov_unsymmetrical_comparer.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2021-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "common_test_utils/test_common.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "openvino/core/model.hpp" + +namespace ov { +namespace test { + +template +class UnsymmetricalComparer : public BaseLayerTest, virtual public ov::test::SubgraphBaseTest { +protected: + ov::Tensor generate_input(const ov::element::Type element_type, const ov::Shape& shape, int seed) const { + return ov::test::utils::create_and_fill_tensor(element_type, shape, 10, 0, 1, seed); + }; + + void generate_inputs(const std::vector& target_input_static_shapes) override { + inputs.clear(); + const auto& func_inputs = function->inputs(); + const int base_seed = 1; + + for (int i = 0; i < func_inputs.size(); ++i) { + + const auto& param = func_inputs[i]; + auto tensor = generate_input(param.get_element_type(), target_input_static_shapes[i], base_seed + i); + inputs.insert({param.get_node_shared_ptr(), tensor}); + } + } +}; +} // namespace test +} // namespace ov From f69117598f683347658264668f37eedf8b9503b1 Mon Sep 17 00:00:00 2001 From: Nadezhda Ageeva Date: Tue, 10 Oct 2023 16:13:45 +0400 Subject: [PATCH 6/7] [NVIDIA] Move Convert, ConvertColorI420, ConvertColorNV12 to API2.0 (#736) --- .../single_layer_tests/convert.cpp | 100 +++------- .../convert_color_common.hpp | 31 +++ .../single_layer_tests/convert_color_i420.cpp | 178 +++++++----------- .../single_layer_tests/convert_color_nv12.cpp | 103 ++++++---- 4 files changed, 190 insertions(+), 222 deletions(-) create mode 100644 modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_common.hpp diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert.cpp index c153ecd06..7406d42f9 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert.cpp @@ -1,96 +1,56 @@ // Copyright (C) 2021-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "single_op_tests/conversion.hpp" +#include "functional_test_utils/skip_tests_config.hpp" #include #include -#include "ie_precision.hpp" -#include "single_layer_tests/conversion.hpp" - -using namespace LayerTestsDefinitions; -using namespace InferenceEngine; +namespace { -namespace CUDALayerTestsDefinitions { +using namespace ov::test; +using namespace ov::test::utils; class ConversionCUDALayerTest : public ConversionLayerTest {}; -TEST_P(ConversionCUDALayerTest, CompareWithRefs) { +TEST_P(ConversionCUDALayerTest, Inference) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - - ConversionParamsTuple params = GetParam(); - inPrc = std::get<2>(params); - outPrc = std::get<3>(params); - - Run(); + run(); } -namespace { -const std::vector conversionOpTypes = { - ngraph::helpers::ConversionTypes::CONVERT, +const std::vector conversion_op_types = { + ConversionTypes::CONVERT, }; -const std::vector> inShape = {{1, 2, 3, 4}}; +const std::vector in_shapes = {{1, 2, 3, 4}}; // List of precisions natively supported by CUDA. -// CUDA device supports only U8, FP16 and FP32 output precision -const std::vector out_precisions = { - Precision::U8, - Precision::FP16, - Precision::FP32, +// CUDA device supports only u8, f16 and f32 output precision +const std::vector out_precisions = { + ov::element::u8, + ov::element::i16, + ov::element::f16, + ov::element::bf16, + ov::element::f32, }; -// Supported formats are: BOOL, FP32, FP16, I16 and U8 -const std::vector in_precisions = { - Precision::BOOL, - Precision::U8, - Precision::I16, - // TODO: Uncomment when we find way to omit conversion from FP16 -> FP32 in tests - // Precision::FP16, - Precision::FP32, +// Supported formats are: boolean, f32, f6, i16 and u8 +const std::vector in_precisions = { + ov::element::boolean, + ov::element::u8, + ov::element::i16, + ov::element::f16, + ov::element::bf16, + ov::element::f32, }; -INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest_From_F32, +INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest, ConversionCUDALayerTest, - ::testing::Combine(::testing::ValuesIn(conversionOpTypes), - ::testing::Values(inShape), - ::testing::Values(Precision::FP32), - ::testing::ValuesIn(out_precisions), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), - ConversionLayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest_To_F32, - ConversionCUDALayerTest, - ::testing::Combine(::testing::ValuesIn(conversionOpTypes), - ::testing::Values(inShape), + ::testing::Combine(::testing::ValuesIn(conversion_op_types), + ::testing::Values(static_shapes_to_test_representation(in_shapes)), ::testing::ValuesIn(in_precisions), - ::testing::Values(Precision::FP32), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), + ::testing::ValuesIn(out_precisions), + ::testing::Values(DEVICE_NVIDIA)), ConversionLayerTest::getTestCaseName); - -/* TODO Uncomment when BF16 support is implemented -INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest_From_BF16, ConversionCUDALayerTest, - ::testing::Combine( - ::testing::Values(inShape), - ::testing::Values(Precision::BF16), - ::testing::ValuesIn(precisions), - ::testing::Values(Layout::ANY), - ::testing::Values(Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), - ConvertLayerTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_ConvertLayerTest_To_BF16, ConversionCUDALayerTest, - ::testing::Combine( - ::testing::Values(inShape), - ::testing::ValuesIn(precisions), - ::testing::Values(Precision::BF16), - ::testing::Values(Layout::ANY), - ::testing::Values(Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)), - ConvertLayerTest::getTestCaseName); -*/ } // namespace -} // namespace CUDALayerTestsDefinitions diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_common.hpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_common.hpp new file mode 100644 index 000000000..235919bf9 --- /dev/null +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_common.hpp @@ -0,0 +1,31 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { +namespace nvidia_gpu { + +class ConvertColorCUDALayerTest : virtual public ov::test::SubgraphBaseTest { +private: + ov::Tensor generate_input(const ov::element::Type element_type, const ov::Shape& shape) const { + return utils::create_and_fill_tensor(element_type, shape, 255); + }; + void generate_inputs(const std::vector& target_input_static_shapes) override { + inputs.clear(); + const auto& func_inputs = function->inputs(); + for (int i = 0; i < func_inputs.size(); ++i) { + const auto& param = func_inputs[i]; + auto tensor = generate_input(param.get_element_type(), target_input_static_shapes[i]); + inputs.insert({param.get_node_shared_ptr(), tensor}); + } + } +}; +} // nvidia_gpu +} // test +} // ov diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_i420.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_i420.cpp index ef0eabc02..acfc19891 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_i420.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_i420.cpp @@ -2,104 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/convert_color_i420.hpp" +#include "single_op_tests/convert_color_i420.hpp" +#include "convert_color_common.hpp" -#include +#include "cuda_test_constants.hpp" #include -using namespace LayerTestsDefinitions; - namespace { -class ConvertColorI420CUDALayerTest : public ConvertColorI420LayerTest { -private: - void SetUp() override { - ov::Shape inputShape; - ov::element::Type ngPrc; - bool conversionToRGB, singlePlane; - abs_threshold = 1.0f; // I420 conversion can use various algorithms, thus some absolute deviation is allowed - threshold = 1.f; // Ignore relative comparison for I420 convert (allow 100% relative deviation) - std::tie(inputShape, ngPrc, conversionToRGB, singlePlane, targetDevice) = GetParam(); - if (singlePlane) { - inputShape[1] = inputShape[1] * 3 / 2; - auto param = std::make_shared(ngPrc, inputShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param); - } else { - convert_color = std::make_shared(param); - } - function = std::make_shared( - std::make_shared(convert_color), ov::ParameterVector{param}, "ConvertColorI420"); - } else { - auto uvShape = ov::Shape{inputShape[0], inputShape[1] / 2, inputShape[2] / 2, 1}; - auto param_y = std::make_shared(ngPrc, inputShape); - auto param_u = std::make_shared(ngPrc, uvShape); - auto param_v = std::make_shared(ngPrc, uvShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param_y, param_u, param_v); - } else { - convert_color = std::make_shared(param_y, param_u, param_v); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param_y, param_u, param_v}, - "ConvertColorI420"); - } - } - - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const override { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 255); - } -}; +using namespace ov::test; +using namespace ov::test::nvidia_gpu; +using namespace ov::test::utils; -TEST_P(ConvertColorI420CUDALayerTest, CompareWithRefs) { Run(); } - -class ConvertColorI420CUDAAccuracyTest : public ConvertColorI420AccuracyTest { -private: - void SetUp() override { - ov::Shape inputShape; - ov::element::Type ngPrc; - bool conversionToRGB, singlePlane; - abs_threshold = 1.0f; // I420 conversion can use various algorithms, thus some absolute deviation is allowed - threshold = 1.f; // Ignore relative comparison for I420 convert (allow 100% relative deviation) - std::tie(inputShape, ngPrc, conversionToRGB, singlePlane, targetDevice) = GetParam(); - if (singlePlane) { - inputShape[1] = inputShape[1] * 3 / 2; - auto param = std::make_shared(ngPrc, inputShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param); - } else { - convert_color = std::make_shared(param); - } - function = std::make_shared( - std::make_shared(convert_color), ov::ParameterVector{param}, "ConvertColorI420"); - } else { - auto uvShape = ov::Shape{inputShape[0], inputShape[1] / 2, inputShape[2] / 2, 1}; - auto param_y = std::make_shared(ngPrc, inputShape); - auto param_u = std::make_shared(ngPrc, uvShape); - auto param_v = std::make_shared(ngPrc, uvShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param_y, param_u, param_v); - } else { - convert_color = std::make_shared(param_y, param_u, param_v); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param_y, param_u, param_v}, - "ConvertColorI420"); - } - } - - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const override { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 255); - } -}; +class ConvertColorI420CUDALayerTest : public ConvertColorCUDALayerTest, public ConvertColorI420LayerTest {}; -TEST_P(ConvertColorI420CUDAAccuracyTest, CompareWithRefs) { Run(); } +TEST_P(ConvertColorI420CUDALayerTest, Inference) { run(); } -const std::vector inShapes_nhwc = { +const std::vector in_shapes_nhwc = { {1, 10, 10, 1}, {1, 50, 10, 1}, {1, 100, 10, 1}, @@ -112,43 +31,78 @@ const std::vector inShapes_nhwc = { {1, 96, 16, 1}, }; -const std::vector inTypes = { +auto generate_input_static_shapes = [] (const std::vector& original_shapes, bool single_plane) { + std::vector> result_shapes; + for (const auto& original_shape : original_shapes) { + std::vector one_result_shapes; + if (single_plane) { + auto shape = original_shape; + shape[1] = shape[1] * 3 / 2; + one_result_shapes.push_back(shape); + } else { + auto shape = original_shape; + one_result_shapes.push_back(shape); + auto uvShape = ov::Shape{shape[0], shape[1] / 2, shape[2] / 2, 1}; + one_result_shapes.push_back(uvShape); + one_result_shapes.push_back(uvShape); + } + result_shapes.push_back(one_result_shapes); + } + return result_shapes; +}; + +auto in_shapes_single_plain_static = generate_input_static_shapes(in_shapes_nhwc, true); +auto in_shapes_not_single_plain_static = generate_input_static_shapes(in_shapes_nhwc, false); + +const std::vector in_types = { ov::element::u8, ov::element::f32, ov::element::f16, }; -const auto testCase_values = ::testing::Combine(::testing::ValuesIn(inShapes_nhwc), - ::testing::ValuesIn(inTypes), - ::testing::Bool(), - ::testing::Bool(), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto test_case_values_single_plain = ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(in_shapes_single_plain_static)), + ::testing::ValuesIn(in_types), + ::testing::Bool(), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); -INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorI420, +INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorI420_single_plain, ConvertColorI420CUDALayerTest, - testCase_values, + test_case_values_single_plain, ConvertColorI420CUDALayerTest::getTestCaseName); -const auto testCase_accuracy_values = ::testing::Combine(::testing::Values(ov::Shape{1, 96, 16, 1}), - ::testing::Values(ov::element::u8), - ::testing::Values(false), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto test_case_values_not_single_plain = ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(in_shapes_not_single_plain_static)), + ::testing::ValuesIn(in_types), + ::testing::Bool(), + ::testing::Values(false), + ::testing::Values(DEVICE_NVIDIA)); + +INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorI420_not_single_plain, + ConvertColorI420CUDALayerTest, + test_case_values_not_single_plain, + ConvertColorI420CUDALayerTest::getTestCaseName); + + +const auto test_case_accuracy_values = ::testing::Combine(::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 96, 16, 1}})), + ::testing::Values(ov::element::u8), + ::testing::Values(false), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorI420_acc, - ConvertColorI420CUDAAccuracyTest, - testCase_accuracy_values, + ConvertColorI420CUDALayerTest, + test_case_accuracy_values, ConvertColorI420CUDALayerTest::getTestCaseName); -const auto testCase_accuracy_values_nightly = ::testing::Combine(::testing::Values(ov::Shape{1, 65536, 256, 1}), - ::testing::Values(ov::element::u8), - ::testing::Values(false), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto test_case_accuracy_values_nightly = ::testing::Combine(::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 65538, 256, 1}})), + ::testing::Values(ov::element::u8), + ::testing::Values(false), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); INSTANTIATE_TEST_SUITE_P(nightly_TestsConvertColorI420_acc, - ConvertColorI420CUDAAccuracyTest, - testCase_accuracy_values_nightly, + ConvertColorI420CUDALayerTest, + test_case_accuracy_values_nightly, ConvertColorI420CUDALayerTest::getTestCaseName); } // namespace diff --git a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_nv12.cpp b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_nv12.cpp index eacc64a0e..173f7a7aa 100644 --- a/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_nv12.cpp +++ b/modules/nvidia_plugin/tests/functional/shared_tests_instances/single_layer_tests/convert_color_nv12.cpp @@ -2,25 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/convert_color_nv12.hpp" +#include "single_op_tests/convert_color_nv12.hpp" +#include "convert_color_common.hpp" #include #include -using namespace LayerTestsDefinitions; - namespace { -class ConvertColorNV12CUDALayerTest : public ConvertColorNV12LayerTest { -private: - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const override { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 255); - } -}; +using namespace ov::test; +using namespace ov::test::nvidia_gpu; +using namespace ov::test::utils; + +class ConvertColorNV12CUDALayerTest : public ConvertColorCUDALayerTest, public ConvertColorNV12LayerTest {}; -TEST_P(ConvertColorNV12CUDALayerTest, CompareWithRefs) { Run(); } +TEST_P(ConvertColorNV12CUDALayerTest, Inference) { run(); } -const std::vector inShapes_nhwc = { +const std::vector in_shapes_nhwc = { {1, 10, 10, 1}, {1, 50, 10, 1}, {1, 100, 10, 1}, @@ -33,52 +31,77 @@ const std::vector inShapes_nhwc = { {1, 96, 16, 1}, }; -const std::vector inTypes = { +auto generate_input_static_shapes = [] (const std::vector& original_shapes, bool single_plane) { + std::vector> result_shapes; + for (const auto& original_shape : original_shapes) { + std::vector one_result_shapes; + if (single_plane) { + auto shape = original_shape; + shape[1] = shape[1] * 3 / 2; + one_result_shapes.push_back(shape); + } else { + auto shape = original_shape; + one_result_shapes.push_back(shape); + auto uvShape = ov::Shape{shape[0], shape[1] / 2, shape[2] / 2, 2}; + one_result_shapes.push_back(uvShape); + } + result_shapes.push_back(one_result_shapes); + } + return result_shapes; +}; + +auto in_shapes_single_plain_static = generate_input_static_shapes(in_shapes_nhwc, true); +auto in_shapes_not_single_plain_static = generate_input_static_shapes(in_shapes_nhwc, false); + +const std::vector in_types = { ov::element::u8, ov::element::f32, ov::element::f16, }; -const auto testCase_values = ::testing::Combine(::testing::ValuesIn(inShapes_nhwc), - ::testing::ValuesIn(inTypes), - ::testing::Bool(), - ::testing::Bool(), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto test_case_values_single_plain = ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(in_shapes_single_plain_static)), + ::testing::ValuesIn(in_types), + ::testing::Bool(), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); -INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorNV12, +INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorNV12_single_plain, ConvertColorNV12CUDALayerTest, - testCase_values, + test_case_values_single_plain, ConvertColorNV12CUDALayerTest::getTestCaseName); -class ConvertColorNV12CUDAAccuracyTest : public ConvertColorNV12AccuracyTest { -private: - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const override { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 255); - } -}; +const auto test_case_values_not_single_plain = ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(in_shapes_not_single_plain_static)), + ::testing::ValuesIn(in_types), + ::testing::Bool(), + ::testing::Values(false), + ::testing::Values(DEVICE_NVIDIA)); -TEST_P(ConvertColorNV12CUDAAccuracyTest, CompareWithRefs) { Run(); } +INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorNV12_not_single_plain, + ConvertColorNV12CUDALayerTest, + test_case_values_not_single_plain, + ConvertColorNV12CUDALayerTest::getTestCaseName); -const auto testCase_accuracy_values = ::testing::Combine(::testing::Values(ov::Shape{1, 96, 16, 1}), - ::testing::Values(ov::element::u8), - ::testing::Values(false), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); + +const auto test_case_accuracy_values = ::testing::Combine(::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 96, 16, 1}})), + ::testing::Values(ov::element::u8), + ::testing::Values(false), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); INSTANTIATE_TEST_SUITE_P(smoke_TestsConvertColorNV12_acc, - ConvertColorNV12CUDAAccuracyTest, - testCase_accuracy_values, + ConvertColorNV12CUDALayerTest, + test_case_accuracy_values, ConvertColorNV12LayerTest::getTestCaseName); -const auto testCase_accuracy_values_nightly = ::testing::Combine(::testing::Values(ov::Shape{1, 65536, 256, 1}), - ::testing::Values(ov::element::u8), - ::testing::Values(false), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_NVIDIA)); +const auto test_case_accuracy_values_nightly = ::testing::Combine(::testing::Values(static_shapes_to_test_representation({ov::Shape{1, 65538, 256, 1}})), + ::testing::Values(ov::element::u8), + ::testing::Values(false), + ::testing::Values(true), + ::testing::Values(DEVICE_NVIDIA)); INSTANTIATE_TEST_SUITE_P(nightly_TestsConvertColorNV12_acc, - ConvertColorNV12CUDAAccuracyTest, - testCase_accuracy_values_nightly, + ConvertColorNV12CUDALayerTest, + test_case_accuracy_values_nightly, ConvertColorNV12LayerTest::getTestCaseName); } // namespace From b21bc7c6517f8dcb60fc290e4bffd751c7768303 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 10 Oct 2023 16:42:30 +0300 Subject: [PATCH 7/7] [NVIDIA] Fix Unit Tests (#745) * Fix unit tests that crashed after change assertion to OPENVINO_ASSERT * Fix MatMul test in case MatMul is not converted to FP16 --------- Co-authored-by: Denis Kotov --- .../nvidia_plugin/tests/unit/compile_model.cpp | 5 ++--- ...cuda_immutable_memory_block_builder_test.cpp | 17 ----------------- .../memory_manager/cuda_memory_manager_test.cpp | 15 --------------- ...cuda_immutable_memory_model_builder_test.cpp | 11 ----------- .../model/cuda_memory_model_builder_test.cpp | 12 ------------ 5 files changed, 2 insertions(+), 58 deletions(-) diff --git a/modules/nvidia_plugin/tests/unit/compile_model.cpp b/modules/nvidia_plugin/tests/unit/compile_model.cpp index 4f1cfa503..934145a17 100644 --- a/modules/nvidia_plugin/tests/unit/compile_model.cpp +++ b/modules/nvidia_plugin/tests/unit/compile_model.cpp @@ -72,10 +72,9 @@ TEST_P(MatMulCompileModelTest, BuildExecutableSequence_MatMul_Success) { auto plugin = std::make_shared(); auto cuda_compiled_model = std::dynamic_pointer_cast(plugin->compile_model(model_, properties)); const auto& execSequence = GetExecSequence(cuda_compiled_model); - bool is_f32 = properties.at(ov::hint::inference_precision.name()).as() == ov::element::f32; - auto expected_ops = is_f32 ? 3 : 5; // +2 Converts for f16 + ASSERT_TRUE(execSequence.size() == 3 || execSequence.size() == 5); + bool is_f32 = execSequence.size() == 3; auto matmul_index = is_f32 ? 1 : 2; - ASSERT_EQ(execSequence.size(), expected_ops); ASSERT_EQ(std::type_index(typeid(*execSequence[matmul_index].get())), std::type_index(typeid(MatMulOp))); } diff --git a/modules/nvidia_plugin/tests/unit/memory_manager/cuda_immutable_memory_block_builder_test.cpp b/modules/nvidia_plugin/tests/unit/memory_manager/cuda_immutable_memory_block_builder_test.cpp index 83f956c7f..13dcb61db 100644 --- a/modules/nvidia_plugin/tests/unit/memory_manager/cuda_immutable_memory_block_builder_test.cpp +++ b/modules/nvidia_plugin/tests/unit/memory_manager/cuda_immutable_memory_block_builder_test.cpp @@ -63,14 +63,8 @@ TEST(ImmutableMemoryBlockBuilder, HandleDuplicateAllocation) { builder.addAllocation(duplicate_buffer_id, &t0_data[0], t0_data.size()); -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, &t0_data[0], t0_data.size()), ov::Exception); ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, &t1_data[0], t1_data.size()), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, &t0_data[0], t0_data.size()), "Assertion"); - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, &t1_data[0], t1_data.size()), "Assertion"); -#endif } TEST(ImmutableMemoryBlockBuilder, HandleZeroAllocationSize) { @@ -81,14 +75,8 @@ TEST(ImmutableMemoryBlockBuilder, HandleZeroAllocationSize) { BufferID buffer_id = 1; const std::vector data(16, 0xA5); -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(buffer_id, &data[0], 0), ov::Exception); ASSERT_THROW(builder.addAllocation(buffer_id, nullptr, 0), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(buffer_id, &data[0], 0), "Assertion"); - ASSERT_DEATH(builder.addAllocation(buffer_id, nullptr, 0), "Assertion"); -#endif } TEST(ImmutableMemoryBlockBuilder, HandleNullDataPointer) { @@ -98,10 +86,5 @@ TEST(ImmutableMemoryBlockBuilder, HandleNullDataPointer) { BufferID buffer_id = 1; -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(buffer_id, nullptr, 128), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(buffer_id, nullptr, 128), "Assertion"); -#endif } diff --git a/modules/nvidia_plugin/tests/unit/memory_manager/cuda_memory_manager_test.cpp b/modules/nvidia_plugin/tests/unit/memory_manager/cuda_memory_manager_test.cpp index 5200b8455..bd4dcf178 100644 --- a/modules/nvidia_plugin/tests/unit/memory_manager/cuda_memory_manager_test.cpp +++ b/modules/nvidia_plugin/tests/unit/memory_manager/cuda_memory_manager_test.cpp @@ -170,12 +170,7 @@ TEST_F(MemoryManagerTest, InvalidInputTensorID) { auto allocation = CUDA::DefaultStream::stream().malloc(immutableTensors_->memoryModel()->deviceMemoryBlockSize() + mutableMemoryModel_->deviceMemoryBlockSize()); -#ifdef NDEBUG ASSERT_THROW(memory_manager->inputTensorPointers(*this, allocation), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(memory_manager->inputTensorPointers(*this, allocation), "Assertion"); -#endif } TEST_F(MemoryManagerTest, InvalidOutputTensorID) { @@ -191,12 +186,7 @@ TEST_F(MemoryManagerTest, InvalidOutputTensorID) { auto allocation = CUDA::DefaultStream::stream().malloc(immutableTensors_->memoryModel()->deviceMemoryBlockSize() + mutableMemoryModel_->deviceMemoryBlockSize()); -#ifdef NDEBUG ASSERT_THROW(memory_manager->outputTensorPointers(*this, allocation), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(memory_manager->outputTensorPointers(*this, allocation), "Assertion"); -#endif } TEST_F(MemoryManagerTest, ConstantsCanNotBeOutputs) { @@ -208,10 +198,5 @@ TEST_F(MemoryManagerTest, ConstantsCanNotBeOutputs) { auto allocation = CUDA::DefaultStream::stream().malloc(immutableTensors_->memoryModel()->deviceMemoryBlockSize() + mutableMemoryModel_->deviceMemoryBlockSize()); -#ifdef NDEBUG ASSERT_THROW(memory_manager->outputTensorPointers(*this, allocation), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(memory_manager->outputTensorPointers(*this, allocation), "Assertion"); -#endif } diff --git a/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_immutable_memory_model_builder_test.cpp b/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_immutable_memory_model_builder_test.cpp index ece68cf63..be5d32739 100644 --- a/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_immutable_memory_model_builder_test.cpp +++ b/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_immutable_memory_model_builder_test.cpp @@ -66,14 +66,8 @@ TEST(ImmutableMemoryModelBuilder, HandleDuplicateAllocation) { builder.addAllocation(duplicate_buffer_id, size1); -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, size1), ov::Exception); ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, size2), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, size1), "Assertion"); - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, size2), "Assertion"); -#endif } TEST(ImmutableMemoryModelBuilder, HandleZeroAllocationSize) { @@ -83,10 +77,5 @@ TEST(ImmutableMemoryModelBuilder, HandleZeroAllocationSize) { BufferID buffer_id = 1; -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(buffer_id, 0), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(buffer_id, 0), "Assertion"); -#endif } diff --git a/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_memory_model_builder_test.cpp b/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_memory_model_builder_test.cpp index 4977e42c2..2f6b68917 100644 --- a/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_memory_model_builder_test.cpp +++ b/modules/nvidia_plugin/tests/unit/memory_manager/model/cuda_memory_model_builder_test.cpp @@ -101,16 +101,9 @@ TEST(MemoryModelBuilder, HandleDuplicateAllocation) { builder.addAllocation(duplicate_buffer_id, 0, 1, size1); -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, 0, 1, size1), ov::Exception); ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, 0, 1, size2), ov::Exception); ASSERT_THROW(builder.addAllocation(duplicate_buffer_id, 1, 2, size1), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, 0, 1, size1), "Assertion"); - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, 0, 1, size2), "Assertion"); - ASSERT_DEATH(builder.addAllocation(duplicate_buffer_id, 1, 2, size1), "Assertion"); -#endif } TEST(MemoryModelBuilder, HandleZeroAllocationSize) { @@ -121,12 +114,7 @@ TEST(MemoryModelBuilder, HandleZeroAllocationSize) { BufferID buffer_id = 1; const size_t size = 0; -#ifdef NDEBUG ASSERT_THROW(builder.addAllocation(buffer_id, 0, 1, size), ov::Exception); -#else - testing::FLAGS_gtest_death_test_style = "threadsafe"; - ASSERT_DEATH(builder.addAllocation(buffer_id, 0, 1, size), "Assertion"); -#endif } /*