From 6f7cf2884792e0800e8795603a41c174e8bb5701 Mon Sep 17 00:00:00 2001 From: Tomasz Jankowski Date: Wed, 22 May 2024 19:17:04 +0200 Subject: [PATCH] [Tmpl test] ExperimentalDetectronPriorGridGenerator: Drop legacy comparison (#24592) ### Details: - Removed 'actual comparison size' parameter from base template test class `CommonReferenceTest`. - Moved partial comparison logic to `ReferenceExperimentalPGGLayerTest::Validate()` - it's needed only in this test. ### Tickets: - CVS-137159 --- .../op_reference/base_reference_test.cpp | 15 ++---- .../op_reference/base_reference_test.hpp | 8 ++-- ...imental_detectron_detection_prior_grid.cpp | 46 ++++++++++++------- .../tests/functional/op_reference/memory.cpp | 3 +- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp index 239405dbca6b19..f457ab09b90846 100644 --- a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp +++ b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp @@ -76,13 +76,7 @@ void CommonReferenceTest::Validate() { ASSERT_EQ(refOutData.size(), actualOutData.size()); for (size_t i = 0; i < refOutData.size(); i++) { - ValidateBlobs(refOutData[i], - actualOutData[i], - i, - threshold, - abs_threshold, - legacy_compare, - actual_comparision_size); + ValidateBlobs(refOutData[i], actualOutData[i], i, threshold, abs_threshold, legacy_compare); } } @@ -91,15 +85,12 @@ void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob, const size_t blob_idx, float threshold, float abs_threshold, - bool legacy_compare, - size_t actual_comparision_size) { + bool legacy_compare) { ASSERT_EQ(refBlob.get_element_type(), outBlob.get_element_type()) << "Incompatible element type for blob with index " << blob_idx; ASSERT_EQ(refBlob.get_byte_size(), outBlob.get_byte_size()) << "Incorrect byte size for blob with index " << blob_idx; - if (actual_comparision_size == 0) - actual_comparision_size = refBlob.get_size(); // compare() get fundamental element type with element_type_traits firstly and cast data to relative ov type with // 'from' types listed below have a fundamental analogue as int8_t, but int8_t is converted only to i8 with from std::vector raw_data_comp_only = @@ -133,6 +124,8 @@ void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob, } return; } + + const auto actual_comparision_size = refBlob.get_size(); switch (element_type) { case ov::element::bf16: ov::test::utils::compare_raw_data(refBlob.data(), diff --git a/src/plugins/template/tests/functional/op_reference/base_reference_test.hpp b/src/plugins/template/tests/functional/op_reference/base_reference_test.hpp index 94923ca58cb8ef..a228c908850b42 100644 --- a/src/plugins/template/tests/functional/op_reference/base_reference_test.hpp +++ b/src/plugins/template/tests/functional/op_reference/base_reference_test.hpp @@ -28,8 +28,7 @@ class CommonReferenceTest { const size_t blob_idx, float threshold, float abs_threshold, - bool legacy_compare, - size_t actual_comparision_size); + bool legacy_compare); protected: bool legacy_compare = false; @@ -42,9 +41,8 @@ class CommonReferenceTest { std::vector inputData; std::vector refOutData; std::vector actualOutData; - float threshold = 1e-2f; // Relative diff - float abs_threshold = -1.f; // Absolute diff (not used when negative) - size_t actual_comparision_size = 0; // For ref output data is smaller than output blob size + float threshold = 1e-2f; // Relative diff + float abs_threshold = -1.f; // Absolute diff (not used when negative) }; template diff --git a/src/plugins/template/tests/functional/op_reference/experimental_detectron_detection_prior_grid.cpp b/src/plugins/template/tests/functional/op_reference/experimental_detectron_detection_prior_grid.cpp index 5450c11a74a41e..58d577cb6a06aa 100644 --- a/src/plugins/template/tests/functional/op_reference/experimental_detectron_detection_prior_grid.cpp +++ b/src/plugins/template/tests/functional/op_reference/experimental_detectron_detection_prior_grid.cpp @@ -7,9 +7,10 @@ #include "base_reference_test.hpp" #include "openvino/op/experimental_detectron_prior_grid_generator.hpp" -using namespace reference_tests; using namespace ov; +using reference_tests::CommonReferenceTest; +using reference_tests::CreateTensor; using Attrs = op::v6::ExperimentalDetectronPriorGridGenerator::Attributes; namespace { @@ -30,7 +31,6 @@ struct ExperimentalPGGParams { imageSizeInfoShape(imageSizeInfoShape), outRefShape(outRefShape), inType(iType), - outType(iType), priorsData(CreateTensor(iType, priorsValues)), refData(CreateTensor(outRefShape, iType, refValues)), testcaseName(testcaseName) { @@ -54,12 +54,11 @@ struct ExperimentalPGGParams { PartialShape imageSizeInfoShape; Shape outRefShape; size_t actualComparisonSize; - ov::element::Type inType; - ov::element::Type outType; - ov::Tensor priorsData; - ov::Tensor featureMapData; - ov::Tensor imageSizeInfoData; - ov::Tensor refData; + element::Type inType; + Tensor priorsData; + Tensor featureMapData; + Tensor imageSizeInfoData; + Tensor refData; std::string testcaseName; }; @@ -67,23 +66,18 @@ class ReferenceExperimentalPGGLayerTest : public testing::TestWithParam 0) - actual_comparision_size = params.actualComparisonSize; } static std::string getTestCaseName(const testing::TestParamInfo& obj) { - auto param = obj.param; + const auto& param = obj.param; std::ostringstream result; result << "priorsShape=" << param.priorsShape << "_"; result << "featureMapShape=" << param.featureMapShape << "_"; result << "imageSizeInfoShape=" << param.imageSizeInfoShape << "_"; result << "iType=" << param.inType << "_"; - result << "oType=" << param.outType << "_"; result << "flatten=" << param.attrs.flatten << "_"; result << "h=" << param.attrs.h << "_"; result << "w=" << param.attrs.w << "_"; @@ -94,6 +88,26 @@ class ReferenceExperimentalPGGLayerTest : public testing::TestWithParam CreateFunction(const ExperimentalPGGParams& params) { const auto priors = std::make_shared(params.inType, params.priorsShape); @@ -103,7 +117,7 @@ class ReferenceExperimentalPGGLayerTest : public testing::TestWithParam(NodeVector{ExperimentalPGG}, ParameterVector{priors, featureMap, im_info}); + return std::make_shared(NodeVector{ExperimentalPGG}, ParameterVector{priors, featureMap, im_info}); } }; diff --git a/src/plugins/template/tests/functional/op_reference/memory.cpp b/src/plugins/template/tests/functional/op_reference/memory.cpp index 59ad59106eba66..ef16fae9f73e10 100644 --- a/src/plugins/template/tests/functional/op_reference/memory.cpp +++ b/src/plugins/template/tests/functional/op_reference/memory.cpp @@ -302,8 +302,7 @@ class ReferenceMemoryTest : public testing::TestWithParam { i, 1e-2f, -1.f, - true, - 0); + true); } }