From: Aaron Greig Date: Wed, 31 Mar 2021 09:16:19 +0000 (+0100) Subject: Relax accuracy requirements in the OpenCL sqrt perf arithmetic test. X-Git-Tag: submit/tizen/20220120.021815~1^2~1^2~75^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3f46096d6cdc226fe4a16279275b3dc13cebe90;p=platform%2Fupstream%2Fopencv.git Relax accuracy requirements in the OpenCL sqrt perf arithmetic test. Also bring perf_imgproc CornerMinEigenVal accuracy requirements in line with the test_imgproc accuracy requirements on that test and fix indentation on the latter. Partially addresses issue #9821 --- diff --git a/modules/core/perf/opencl/perf_arithm.cpp b/modules/core/perf/opencl/perf_arithm.cpp index 9f5f6e9e77..0cbfc2d653 100644 --- a/modules/core/perf/opencl/perf_arithm.cpp +++ b/modules/core/perf/opencl/perf_arithm.cpp @@ -678,7 +678,12 @@ OCL_PERF_TEST_P(SqrtFixture, Sqrt, ::testing::Combine( OCL_TEST_CYCLE() cv::sqrt(src, dst); - if (CV_MAT_DEPTH(type) >= CV_32F) + // To square root 32 bit floats we use native_sqrt, which has implementation + // defined accuracy. We know intel devices have accurate native_sqrt, but + // otherwise stick to a relaxed sanity check. For types larger than 32 bits + // we can do the accuracy check for all devices as normal. + if (CV_MAT_DEPTH(type) > CV_32F || !ocl::useOpenCL() || + ocl::Device::getDefault().isIntel()) SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE); else SANITY_CHECK(dst, 1); diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index 4b61976553..db4c4ef451 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -166,7 +166,17 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal, OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType); - SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); +#ifdef HAVE_OPENCL + bool strictCheck = !ocl::useOpenCL() || ocl::Device::getDefault().isIntel(); +#else + bool strictCheck = true; +#endif + + // using native_* OpenCL functions on non-intel devices may lose accuracy + if (strictCheck) + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); + else + SANITY_CHECK(dst, 0.1, ERROR_RELATIVE); } ///////////// CornerHarris //////////////////////// diff --git a/modules/imgproc/test/ocl/test_imgproc.cpp b/modules/imgproc/test/ocl/test_imgproc.cpp index 35185d339f..f3e9f4bb20 100644 --- a/modules/imgproc/test/ocl/test_imgproc.cpp +++ b/modules/imgproc/test/ocl/test_imgproc.cpp @@ -234,10 +234,12 @@ OCL_TEST_P(CornerMinEigenVal, Mat) OCL_OFF(cv::cornerMinEigenVal(src_roi, dst_roi, blockSize, apertureSize, borderType)); OCL_ON(cv::cornerMinEigenVal(usrc_roi, udst_roi, blockSize, apertureSize, borderType)); - if (ocl::Device::getDefault().isIntel()) - Near(1e-5, true); + // The corner kernel uses native_sqrt() which has implementation defined accuracy. + // If we're using a CL implementation that isn't intel, test with relaxed accuracy. + if (!ocl::useOpenCL() || ocl::Device::getDefault().isIntel()) + Near(1e-5, true); else - Near(0.1, true); // using native_* OpenCL functions may lose accuracy + Near(0.1, true); } }