diff --git a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp index 949e2f0c0c1ae0..083f6eae0cd013 100644 --- a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp @@ -362,8 +362,8 @@ inline double calculate_median(std::vector& abs_values) { template void compare(const ov::Tensor& expected, const ov::Tensor& actual, - const double abs_threshold_ = 0, - const double rel_threshold_ = 0) { + const double abs_threshold_ = std::numeric_limits::max(), + const double rel_threshold_ = std::numeric_limits::max()) { auto expected_shape = expected.get_shape(); auto actual_shape = actual.get_shape(); if (expected_shape != actual_shape) { @@ -380,36 +380,17 @@ void compare(const ov::Tensor& expected, double abs_threshold = abs_threshold_; double rel_threshold = rel_threshold_; size_t shape_size_cnt = shape_size(expected_shape); - if (abs_threshold == 0 && rel_threshold == 0) { + if (abs_threshold == std::numeric_limits::max() && rel_threshold == std::numeric_limits::max()) { if (sizeof(ExpectedT) == 1 || sizeof(ActualT) == 1) { abs_threshold = 1.; - rel_threshold = 1.; - if (expected.get_element_type() == ov::element::Type_t::boolean) { - abs_threshold = 0.; - rel_threshold = 0.; - } } else { std::vector abs_values(shape_size_cnt); for (size_t i = 0; i < shape_size_cnt; i++) { abs_values[i] = std::fabs(static_cast(expected_data[i])); } auto abs_median = calculate_median(abs_values); - auto elem_type = expected.get_element_type(); - abs_threshold = abs_median * 0.05 < 1e-5 ? 1e-5 : 0.05 * abs_median; - if (elem_type == ov::element::Type_t::boolean) { - abs_threshold = 0.; - } else if (elem_type.is_integral_number()) { - abs_threshold = 1.0; - } else if (elem_type == ov::element::Type_t::f32 || elem_type == ov::element::Type_t::f64) { - abs_threshold = abs_median * 0.05 < 1e-5 ? 1e-5 : 0.05 * abs_median; - } else if (elem_type == ov::element::Type_t::bf16 || elem_type == ov::element::Type_t::f16) { - abs_threshold = abs_median * 0.05 < 1e-3 ? 1e-3 : 0.05 * abs_median; - } - - rel_threshold = abs_threshold; - if (std::is_integral::value) { abs_threshold = std::ceil(abs_threshold); } @@ -451,12 +432,7 @@ void compare(const ov::Tensor& expected, } double abs = std::fabs(expected_value - actual_value); - double rel = 0; - if (expected_value == 0 || actual_value == 0) { - rel = (std::abs(expected_value) >= 1 || std::abs(actual_value) >= 1) ? (abs * 1e-2) : abs; - } else if (!std::isinf(expected_value)) { - rel = (abs / std::fabs(expected_value)); - } + double rel = expected_value ? (abs / std::fabs(expected_value)) : abs; abs_error.update(abs, i); rel_error.update(rel, i); @@ -464,7 +440,7 @@ void compare(const ov::Tensor& expected, abs_error.mean /= shape_size_cnt; rel_error.mean /= shape_size_cnt; - if (!(less_or_equal(abs_error.max, abs_threshold) || less_or_equal(rel_error.mean, rel_threshold))) { + if (!(less_or_equal(abs_error.max, abs_threshold) && less_or_equal(rel_error.max, rel_threshold))) { std::ostringstream out_stream; out_stream << "abs_max < abs_threshold && rel_max < rel_threshold" << "\n\t abs_max: " << abs_error.max << "\n\t\t coordinate " << abs_error.max_coordinate