OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Template] Drop legacy comparison where possible (#38412)
Tomasz Jankowskia3a511cb5728
diff --git a/src/plugins/template/tests/functional/op_reference/atanh.cpp b/src/plugins/template/tests/functional/op_reference/atanh.cppindex 1c716a85e9f..a7006ef3882 100644--- a/src/plugins/template/tests/functional/op_reference/atanh.cpp+++ b/src/plugins/template/tests/functional/op_reference/atanh.cpp@@ -28,14 +28,19 @@ struct Builder : ParamsBuilder<AtanhParams> {class ReferenceAtanhLayerTest : public testing::TestWithParam<AtanhParams>, public CommonReferenceTest {public:void SetUp() override {+ /* Keep the legacy comparator for this test. Its expected outputs explicitly include ±INFINITY, but the modern+ * comparator skips a value pair whenever both operands are classified as out-of-limits; consequently, an actual+ * NaN is not compared against an expected infinity and the Atanh test can pass with the wrong special value.+ * Enabling the legacy path here preserves the existing NaN-vs-infinity failure check until the modern+ * comparator handles special values strictly. */legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();function = CreateFunction(params.input.shape, params.input.type);inputData = {params.input.data};refOutData = {params.expected.data};}static std::string getTestCaseName(const testing::TestParamInfo<AtanhParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "shape=" << param.input.shape << "_";result << "type=" << param.input.type;diff --git a/src/plugins/template/tests/functional/op_reference/cum_sum.cpp b/src/plugins/template/tests/functional/op_reference/cum_sum.cppindex 2b32d0c1672..a7782901ef4 100644--- a/src/plugins/template/tests/functional/op_reference/cum_sum.cpp+++ b/src/plugins/template/tests/functional/op_reference/cum_sum.cpp@@ -70,8 +70,7 @@ struct CumSumParams {class ReferenceCumSumLayerTest : public testing::TestWithParam<CumSumParams>, public CommonReferenceTest {public:void SetUp() override {- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();if (params.testDefaults) {function = CreateFunction(params.inShape, params.inType);inputData = {params.inputData};@@ -88,7 +87,7 @@ public:}}static std::string getTestCaseName(const testing::TestParamInfo<CumSumParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "testDefaults=" << param.testDefaults << "_";result << "axisValue=" << param.axisValue << "_";diff --git a/src/plugins/template/tests/functional/op_reference/lstm_sequence.cpp b/src/plugins/template/tests/functional/op_reference/lstm_sequence.cppindex fa7459306ae..82991e30f82 100644--- a/src/plugins/template/tests/functional/op_reference/lstm_sequence.cpp+++ b/src/plugins/template/tests/functional/op_reference/lstm_sequence.cpp@@ -6,6 +6,8 @@#include <gtest/gtest.h>+#include <limits>+#include "base_reference_test.hpp"using namespace reference_tests;@@ -176,8 +178,11 @@ struct LSTMSequenceV1Params {class ReferenceLSTMSequenceTest : public testing::TestWithParam<LSTMSequenceParams>, public CommonReferenceTest {public:void SetUp() override {- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();+ if (params.iType == element::Type_t::f64) {+ // Refs were generated in f32; saturated gates make the near-zero outputs relatively sensitive.+ abs_threshold = std::numeric_limits<float>::epsilon();+ }function = CreateFunction(params);inputData = {params.X.data,params.H_t.data,@@ -190,7 +195,7 @@ public:}static std::string getTestCaseName(const testing::TestParamInfo<LSTMSequenceParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "iType=" << param.iType << "_";result << "xShape=" << param.X.shape << "_";diff --git a/src/plugins/template/tests/functional/op_reference/matrix_nms.cpp b/src/plugins/template/tests/functional/op_reference/matrix_nms.cppindex d94703adaf5..812d30c6211 100644--- a/src/plugins/template/tests/functional/op_reference/matrix_nms.cpp+++ b/src/plugins/template/tests/functional/op_reference/matrix_nms.cpp@@ -41,8 +41,7 @@ struct MatrixNmsParams {class ReferenceMatrixNmsTest : public testing::TestWithParam<MatrixNmsParams>, public CommonReferenceTest {public:void SetUp() override {- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();function = CreateFunction(params);inputData = {params.boxes.data, params.scores.data};refOutData = {params.expectedSelectedScores.data,@@ -51,7 +50,7 @@ public:}static std::string getTestCaseName(const testing::TestParamInfo<MatrixNmsParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "bType=" << param.boxes.type;result << "_bShape=" << param.boxes.shape;diff --git a/src/plugins/template/tests/functional/op_reference/rnn_sequence.cpp b/src/plugins/template/tests/functional/op_reference/rnn_sequence.cppindex c9df6b4700b..f4479d28361 100644--- a/src/plugins/template/tests/functional/op_reference/rnn_sequence.cpp+++ b/src/plugins/template/tests/functional/op_reference/rnn_sequence.cpp@@ -84,8 +84,11 @@ struct RNNSequenceParams {class ReferenceRNNSequenceTest : public testing::TestWithParam<RNNSequenceParams>, public CommonReferenceTest {public:void SetUp() override {- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();+ if (params.iType == element::Type_t::f16) {+ // Refs hold f64-precision values rounded to f16, while the sequence accumulates f16 error over time steps.+ abs_threshold = 0.01f;+ }function = CreateFunction(params);inputData ={params.X.data, params.H_t.data, params.sequence_lengths.data, params.W.data, params.R.data, params.B.data};@@ -93,7 +96,7 @@ public:}static std::string getTestCaseName(const testing::TestParamInfo<RNNSequenceParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "iType=" << param.iType << "_";result << "xShape=" << param.X.shape << "_";diff --git a/src/plugins/template/tests/functional/op_reference/tensor_iterator.cpp b/src/plugins/template/tests/functional/op_reference/tensor_iterator.cppindex df7702dd854..d751728459f 100644--- a/src/plugins/template/tests/functional/op_reference/tensor_iterator.cpp+++ b/src/plugins/template/tests/functional/op_reference/tensor_iterator.cpp@@ -86,8 +86,7 @@ class ReferenceTILayerTest : public testing::TestWithParam<TensorIteratorParams>public:void SetUp() override {SKIP_IF_CURRENT_TEST_IS_DISABLED()- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();function = params.function->create_function(params.inputs, params.expected_results);inputData.reserve(params.inputs.size());refOutData.reserve(params.expected_results.size());@@ -100,7 +99,7 @@ public:}static std::string getTestCaseName(const testing::TestParamInfo<TensorIteratorParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;return param.test_case_name;}};@@ -484,8 +483,11 @@ class ReferenceTILayerStaticTest : public testing::TestWithParam<TensorIteratorSpublic:void SetUp() override {SKIP_IF_CURRENT_TEST_IS_DISABLED()- legacy_compare = true;- auto params = GetParam();+ const auto& params = GetParam();+ if (params.iType == ov::element::Type_t::f16 && params.body_type == TensorIteratorBodyType::RNN) {+ // Refs hold f64-precision values rounded to f16, while the loop accumulates f16 error over time steps.+ abs_threshold = 0.01f;+ }function = params.function->create_function(params);if (params.body_type == TensorIteratorBodyType::LSTM) {inputData = {params.X.data, params.H_t.data, params.C_t.data};@@ -497,7 +499,7 @@ public:}static std::string getTestCaseName(const testing::TestParamInfo<TensorIteratorStaticParams>& obj) {- auto param = obj.param;+ const auto& param = obj.param;std::ostringstream result;result << "bSize=" << param.batchSize;result << "_iSize=" << param.inputSize;