From dd6f5949c24c89724dc11159e3bf3899018e30d2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 9 Nov 2018 12:46:39 +0300 Subject: [PATCH] gapi(test): use relative error check for Norm/Sum tests --- modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp | 6 ++++-- modules/gapi/test/common/gapi_core_tests_inl.hpp | 6 ++++-- modules/gapi/test/cpu/gapi_core_tests_cpu.cpp | 4 ++-- modules/gapi/test/gpu/gapi_core_tests_gpu.cpp | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp b/modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp index ae5a03260e..f0c1de83ae 100644 --- a/modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp +++ b/modules/gapi/perf/common/gapi_core_perf_tests_inl.hpp @@ -921,7 +921,8 @@ PERF_TEST_P_(SumPerfTest, TestPerformance) // Comparison //////////////////////////////////////////////////////////// { - EXPECT_LE(abs(out_sum[0] - out_sum_ocv[0]), tolerance); + EXPECT_LE(std::abs(out_sum[0] - out_sum_ocv[0]) / std::max(1.0, std::abs(out_sum_ocv[0])), tolerance) + << "OCV=" << out_sum_ocv[0] << " GAPI=" << out_sum[0]; } SANITY_CHECK_NOTHING(); @@ -1041,7 +1042,8 @@ PERF_TEST_P_(NormPerfTest, TestPerformance) // Comparison //////////////////////////////////////////////////////////// { - EXPECT_LE(abs(out_norm[0] - out_norm_ocv[0]), tolerance); + EXPECT_LE(std::abs(out_norm[0] - out_norm_ocv[0]) / std::max(1.0, std::abs(out_norm_ocv[0])), tolerance) + << "OCV=" << out_norm_ocv[0] << " GAPI=" << out_norm[0]; } SANITY_CHECK_NOTHING(); diff --git a/modules/gapi/test/common/gapi_core_tests_inl.hpp b/modules/gapi/test/common/gapi_core_tests_inl.hpp index 6b80680d0e..261edeab13 100644 --- a/modules/gapi/test/common/gapi_core_tests_inl.hpp +++ b/modules/gapi/test/common/gapi_core_tests_inl.hpp @@ -703,7 +703,8 @@ TEST_P(SumTest, AccuracyTest) } // Comparison ////////////////////////////////////////////////////////////// { - EXPECT_LE(abs(out_sum[0] - out_sum_ocv[0]), tolerance); + EXPECT_LE(std::abs(out_sum[0] - out_sum_ocv[0]) / std::max(1.0, std::abs(out_sum_ocv[0])), tolerance) + << "OCV=" << out_sum_ocv[0] << " GAPI=" << out_sum[0]; } } @@ -802,7 +803,8 @@ TEST_P(NormTest, AccuracyTest) // Comparison ////////////////////////////////////////////////////////////// { - EXPECT_LE(abs(out_norm[0] - out_norm_ocv[0]), tolerance); + EXPECT_LE(std::abs(out_norm[0] - out_norm_ocv[0]) / std::max(1.0, std::abs(out_norm_ocv[0])), tolerance) + << "OCV=" << out_norm_ocv[0] << " GAPI=" << out_norm[0]; } } diff --git a/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp b/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp index cc218d1028..4bbba57ba3 100644 --- a/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp +++ b/modules/gapi/test/cpu/gapi_core_tests_cpu.cpp @@ -188,7 +188,7 @@ INSTANTIATE_TEST_CASE_P(SumTestCPU, SumTest, cv::Size(640, 480), cv::Size(128, 128)), /*init output matrices or not*/ testing::Bool(), - Values(0.0), + Values(1e-5), Values(cv::compile_args(CORE_CPU)))); INSTANTIATE_TEST_CASE_P(AbsDiffTestCPU, AbsDiffTest, @@ -224,7 +224,7 @@ INSTANTIATE_TEST_CASE_P(NormTestCPU, NormTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(0.0), + Values(1e-5), Values(cv::compile_args(CORE_CPU))), opencv_test::PrintNormCoreParams()); diff --git a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp index 077df783e9..bd1e76ffe6 100644 --- a/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp +++ b/modules/gapi/test/gpu/gapi_core_tests_gpu.cpp @@ -190,7 +190,7 @@ INSTANTIATE_TEST_CASE_P(SumTestGPU, SumTest, cv::Size(640, 480), cv::Size(128, 128)), /*init output matrices or not*/ testing::Bool(), - Values(0.5), //Values(0.04), //TODO: too relaxed? + Values(1e-3), //TODO: too relaxed? Values(cv::compile_args(CORE_GPU)))); INSTANTIATE_TEST_CASE_P(AbsDiffTestGPU, AbsDiffTest, @@ -226,7 +226,7 @@ INSTANTIATE_TEST_CASE_P(NormTestGPU, NormTest, Values(cv::Size(1280, 720), cv::Size(640, 480), cv::Size(128, 128)), - Values(0.04), //TODO: too relaxed? + Values(1e-3), //TODO: too relaxed? Values(cv::compile_args(CORE_GPU))), opencv_test::PrintNormCoreParams());