nareshmlx/opencv-pr huggingface dataset:
**File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #24397: Added PyTorch fcnresnet101 segmentation conversion cases

**Code Changes:**
```diff
@@ -178,3 +178,15 @@ fcn8s:
   height: 500
   rgb: false
   sample: "segmentation"
+
+fcnresnet101:
+  load_info:
+    url: "https://github.com/onnx/models/raw/fb8271d5d5d9b90dbb1eb5e8e40f8f580fb248b3/vision/object_detection_segmentation/fcn/model/fcn-resnet101-11.onnx"
+    sha1: "e7e76474bf6b73334ab32c4be1374c9e605f5aed"
+  model: "fcn-resnet101-11.onnx"
```

Review comment:
https://github.com/opencv/opencv/pull/24463 going to fix problem with dynamic shapes. So please replace url to https://github.com/onnx/models/raw/fb8271d5d5d9b90dbb1eb5e8e40f8f580fb248b3/vision/object_detection_segmentation/fcn/model/fcn-resnet101-11.onnx
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24294: Removed torch (old torch7) from dnn in 5.x - Merge with https://github.com/opencv/opencv_extra/pull/1097 Completely removed torch (old torc...

**Code Changes:**
```diff
@@ -109,32 +109,11 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h)
     processNet("dnn/tensorflow_inception_graph.pb", "", cv::Size(224, 224), "softmax2");
 }
 
-PERF_TEST_P_(DNNTestNetwork, ENet)
-{
-    if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU) ||
-        (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
-        throw SkipTestException("");
-#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021010000)
```

Review comment:
I suspect that the path should be `dnn/mosaic-9.onnx`
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24294: Removed torch (old torch7) from dnn in 5.x - Merge with https://github.com/opencv/opencv_extra/pull/1097 Completely removed torch (old torc...

**Code Changes:**
```diff
@@ -109,32 +109,11 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h)
     processNet("dnn/tensorflow_inception_graph.pb", "", cv::Size(224, 224), "softmax2");
 }
 
-PERF_TEST_P_(DNNTestNetwork, ENet)
-{
-    if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU) ||
-        (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
-        throw SkipTestException("");
-#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021010000)
```

Review comment:
So is this `mosaic-9.onnx` the missing model?
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24294: Removed torch (old torch7) from dnn in 5.x - Merge with https://github.com/opencv/opencv_extra/pull/1097 Completely removed torch (old torc...

**Code Changes:**
```diff
@@ -109,32 +109,11 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h)
     processNet("dnn/tensorflow_inception_graph.pb", "", cv::Size(224, 224), "softmax2");
 }
 
-PERF_TEST_P_(DNNTestNetwork, ENet)
-{
-    if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU) ||
-        (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
-        throw SkipTestException("");
-#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021010000)
```

Review comment:
Please change the file path according to https://github.com/opencv/opencv_extra/pull/1097/files#r1357831844. I will upload the model to the target place.
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24294: Removed torch (old torch7) from dnn in 5.x - Merge with https://github.com/opencv/opencv_extra/pull/1097 Completely removed torch (old torc...

**Code Changes:**
```diff
@@ -109,32 +109,11 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h)
     processNet("dnn/tensorflow_inception_graph.pb", "", cv::Size(224, 224), "softmax2");
 }
 
-PERF_TEST_P_(DNNTestNetwork, ENet)
-{
-    if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU) ||
-        (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16))
-        throw SkipTestException("");
-#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021010000)
```

Review comment:
This model has been uploaded to every host machines under `dnn/onnx/models`.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #24480: Backport to 4.x: patchNaNs() SIMD acceleration

**Code Changes:**
```diff
@@ -1610,30 +1610,37 @@ void patchNaNs( InputOutputArray _a, double _val )
     const Mat* arrays[] = {&a, 0};
     int* ptrs[1] = {};
     NAryMatIterator it(arrays, (uchar**)ptrs);
-    size_t len = it.size*a.channels();
+    int len = (int)(it.size*a.channels());
     Cv32suf val;
     val.f = (float)_val;
 
-#if (CV_SIMD || CV_SIMD_SCALABLE)
```

Review comment:
It's not relevant. I propose to revert.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #24480: Backport to 4.x: patchNaNs() SIMD acceleration

**Code Changes:**
```diff
@@ -1610,30 +1610,37 @@ void patchNaNs( InputOutputArray _a, double _val )
     const Mat* arrays[] = {&a, 0};
     int* ptrs[1] = {};
     NAryMatIterator it(arrays, (uchar**)ptrs);
-    size_t len = it.size*a.channels();
+    int len = (int)(it.size*a.channels());
     Cv32suf val;
     val.f = (float)_val;
 
-#if (CV_SIMD || CV_SIMD_SCALABLE)
```

Review comment:
1. OK about pointers 2. The loop condition [should be](https://github.com/opencv/opencv/pull/23098#discussion_r1378086229) of a form `j < loop_invariant` and has to be calculated in signed integers to avoid unsigned wrapping over zero, so I propose to let `len` and `j` be ints rather than `size_t`
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -41,6 +41,7 @@
 
 #include "../perf_precomp.hpp"
 #include "opencv2/ts/ocl_perf.hpp"
+#include "opencv2/core/softfloat.hpp"
 
 #ifdef HAVE_OPENCL
 
@@ -1038,14 +1039,40 @@ OCL_PERF_TEST_P(ConvertScaleAbsFixture, ConvertScaleAbs,
 
```

Review comment:
C3 case is the most popular in cv and 3d ops. It makes sense to have it in test suite too.
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()
**Review Line:** 1091

**Code Changes:**
```diff
         for (int y = 0; y < srcSize.height; ++y)
         {
-            float * const ptr = src_.ptr<float>(y);
+            float  *const ptrf = src_.ptr<float>(y);
+            double *const ptrd = src_.ptr<double>(y);
             for (int x = 0; x < srcSize.width; ++x)
-                ptr[x] = (x + y) % 2 == 0 ? std::numeric_limits<float>::quiet_NaN() : ptr[x];
+            {
+                if (depth == CV_32F)
+                {
+                    ptrf[x] = (x + y) % 2 == 0 ? randomNan<float >(rng) : ptrf[x];
```

Review comment:
Please use {} for loop body.
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -41,6 +41,7 @@
 
 #include "../perf_precomp.hpp"
 #include "opencv2/ts/ocl_perf.hpp"
+#include "opencv2/core/softfloat.hpp"
 
 #ifdef HAVE_OPENCL
 
@@ -1038,14 +1039,40 @@ OCL_PERF_TEST_P(ConvertScaleAbsFixture, ConvertScaleAbs,
 
```

Review comment:
The same for C3.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
I propose not duplicate the implementation many times, but stay with template version only for now. Current batch of function copies does not make sense. Template specializations may be added in any moment without existing code modifications.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
This is just a boilerplate code for further SIMD implementations. Will be replace by a real code soon.
**File:** modules/3d/perf/perf_tsdf.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -302,6 +302,9 @@ void renderPointsNormals(InputArray _points, InputArray _normals, OutputArray im
 
     Mat_<Vec4b> img = image.getMat();
 
+    Mat goods;
+    finiteMask(points, goods);
+
     Range range(0, sz.height);
     const int nstripes = -1;
     parallel_for_(range, [&](const Range&)
```

Review comment:
Please remove dead code.
**File:** modules/core/include/opencv2/core.hpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1697,12 +1697,21 @@ elements.
 CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0,
                             double minVal = -DBL_MAX, double maxVal = DBL_MAX);
 
-/** @brief converts NaNs to the given number
-@param a input/output matrix (CV_32F type).
+/** @brief Replaces NaNs by given number
+@param a input/output matrix (CV_32F or CV_64F type)
 @param val value to convert the NaNs
 */
```

Review comment:
"Output matrix of the same size as input of type CV_8UC1" is better, IMHO.
**File:** modules/core/src/opencl/finitemask.cl
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,44 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// This kernel is compiled with the following possible defines:
+//  - srcT, cn: source type and number of channels per pixel
+//  - rowsPerWI: Intel GPU optimization
+//  - DOUBLE_SUPPORT: enable double support if available
+
```

Review comment:
Use actual OpenCV license for new files.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
`channels=5` doesn't throw any exception and do nothing.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
`channels` values are not validated at all. For `channels=5` function does nothing and doesn't throw any exception.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
SIMD optimizations in `core` module should go to `.simd.hpp`.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
still `nan`?
**File:** modules/core/include/opencv2/core.hpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1697,12 +1697,21 @@ elements.
 CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0,
                             double minVal = -DBL_MAX, double maxVal = DBL_MAX);
 
-/** @brief converts NaNs to the given number
-@param a input/output matrix (CV_32F type).
+/** @brief Replaces NaNs by given number
+@param a input/output matrix (CV_32F or CV_64F type)
 @param val value to convert the NaNs
 */
```

Review comment:
Malformed documentation.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
`#if`-related checks should have zero indentation.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
> `CV_SIMD128_64F` `64F` is about `double` (`float64`) type. Using it to limit `int64` processing is wrong.
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
Sure, but this is how to enable int64 comparison in NEON universal intrinsics: [intrin_neon.hpp](https://github.com/opencv/opencv/blob/23dec329b47cf19ce2bbbb623c1467929ac021e3/modules/core/include/opencv2/core/hal/intrin_neon.hpp#L1073)
**File:** modules/core/include/opencv2/core.hpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1697,12 +1697,21 @@ elements.
 CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0,
                             double minVal = -DBL_MAX, double maxVal = DBL_MAX);
 
-/** @brief converts NaNs to the given number
-@param a input/output matrix (CV_32F type).
+/** @brief Replaces NaNs by given number
+@param a input/output matrix (CV_32F or CV_64F type)
 @param val value to convert the NaNs
 */
```

Review comment:
Tried to fix it, hope now it looks better
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
Should I add it through HAL and all SIMD dispatching mechanisms as other functions in `mathfuncs_core.simd.hpp` are done or there are easier ways?
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
Other functions should be handled separately (do not touch them in this PR). At first we need to collect performance for different ISA optimizations for added code: https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options#optimization-developer-guide
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
tab does not make sense here as we select one of two: ``` return isDouble ? GET_OPTIMIZED(patchNaNs_64f) : GET_OPTIMIZED(patchNaNs_32f); ```
**File:** modules/core/src/mathfuncs.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1574,75 +1574,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma
     return true;
 }
 
-#ifdef HAVE_OPENCL
-
-static bool ocl_patchNaNs( InputOutputArray _a, float value )
-{
-    int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
-    ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
```

Review comment:
Since this works now w/o workarounds, I've rewritten it in a more convenient way
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
Arrays of register won't work with Scalable RVV. It should be replaced with 4 variables: `vv0`, `vv1`, `vv2`, `vv3`.
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
Shouldn't this block and related be guarded by `CV_SIMD_64F || CV_SIMD_SCALABLE_64F`?
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
Don't think we need it; all processing is actually done in 64-bit integers
**File:** modules/core/include/opencv2/core.hpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -1697,12 +1697,21 @@ elements.
 CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0,
                             double minVal = -DBL_MAX, double maxVal = DBL_MAX);
 
-/** @brief converts NaNs to the given number
-@param a input/output matrix (CV_32F type).
+/** @brief Replaces NaNs by given number
+@param a input/output matrix (CV_32F or CV_64F type)
 @param val value to convert the NaNs
 */
```

Review comment:
img => input/src there is no reason to limit that for images only.
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -41,6 +41,7 @@
 
 #include "../perf_precomp.hpp"
 #include "opencv2/ts/ocl_perf.hpp"
+#include "opencv2/core/softfloat.hpp"
 
 #ifdef HAVE_OPENCL
 
@@ -1038,14 +1039,40 @@ OCL_PERF_TEST_P(ConvertScaleAbsFixture, ConvertScaleAbs,
 
```

Review comment:
You got 2 same numbers. Don't use `seed`. Use `cv::theRNG()`
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
`v_check_any(v_cmp_mask0 | v_cmp_mask1)` ? --- There is no perf reports for patchNAN perf tests in PR. Optimization of existed functions should be backported to 4.x first.
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
`for` condition in SIMD loops should be `j < loop_invariant`. Don't compute on the fly. See other SIMD loops.
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
> vx_cleanup(); Wrong. There is a tail processing below. Code scope guard should be used instead.
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
Removed `vx_cleanup()`
**File:** modules/core/src/nan_mask.simd.hpp
**Change Type:** added
**Context:** PR #23098: finiteMask() and doubles for patchNaNs()

**Code Changes:**
```diff
@@ -0,0 +1,440 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+#include "precomp.hpp"
+
+namespace cv {
+
```

Review comment:
Removed `vx_cleanup()`, using `CV_INSTRUMENT_REGION()` instead