nareshmlx/opencv-pr huggingface dataset:
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #24382: Enable multicore CUDA compilation
**Review Line:** 362

**Code Changes:**
```diff
 
+  # Tell NVCC the maximum number of threads to be used to execute the compilation steps in parallel
+  # (option --threads was introduced in version 11.2)
+  if(NOT CUDA_VERSION VERSION_LESS "11.2")
+    if(CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT $ENV{CMAKE_BUILD_PARALLEL_LEVEL} STREQUAL "")
+      set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--threads=$ENV{CMAKE_BUILD_PARALLEL_LEVEL}")
+    endif()
+  endif()
+
   message(STATUS "CUDA NVCC target flags: ${CUDA_NVCC_FLAGS}")
 
```

Review comment:
> Also if I use GNU Make, `cmake --build . -j4` will invoke 4 instances of nvcc during parallel build with make and each nvcc instance creates 4 jobs internally. I do not think that it's expected behaviour. The `--threads` makes more sense on Windows with msbuild. It runs nvcc sequentially and internal nvcc parallelism should reduce build time. Is this also true when using ninja on windows? If so should the check ensure that msbuild is being used not MSVC, i.e. something like ```if (CMAKE_GENERATOR MATCHES "Visual Studio")```
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #24382: Enable multicore CUDA compilation
**Review Line:** 362

**Code Changes:**
```diff
 
+  # Tell NVCC the maximum number of threads to be used to execute the compilation steps in parallel
+  # (option --threads was introduced in version 11.2)
+  if(NOT CUDA_VERSION VERSION_LESS "11.2")
+    if(CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT $ENV{CMAKE_BUILD_PARALLEL_LEVEL} STREQUAL "")
+      set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--threads=$ENV{CMAKE_BUILD_PARALLEL_LEVEL}")
+    endif()
+  endif()
+
   message(STATUS "CUDA NVCC target flags: ${CUDA_NVCC_FLAGS}")
 
```

Review comment:
> > Also if I use GNU Make, `cmake --build . -j4` will invoke 4 instances of nvcc during parallel build with make and each nvcc instance creates 4 jobs internally. I do not think that it's expected behaviour. The `--threads` makes more sense on Windows with msbuild. It runs nvcc sequentially and internal nvcc parallelism should reduce build time. > > Is this also true when using ninja on windows? If so should the check ensure that msbuild is being used not MSVC, i.e. something like `if (CMAKE_GENERATOR MATCHES "Visual Studio")` It seems that it is not the case for Ninja on Windows. I've added the generator check.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #21066: Native ONNX to Inference Engine backend

**Code Changes:**
```diff
@@ -1027,14 +1027,14 @@ CV__DNN_INLINE_NS_BEGIN
       *                  * `*.pb` (TensorFlow, https://www.tensorflow.org/)
       *                  * `*.t7` | `*.net` (Torch, http://torch.ch/)
       *                  * `*.weights` (Darknet, https://pjreddie.com/darknet/)
-      *                  * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit)
+      *                  * `*.bin` | `*.onnx` (OpenVINO, https://software.intel.com/openvino-toolkit)
       *                  * `*.onnx` (ONNX, https://onnx.ai/)
       * @param[in] config Text file contains network configuration. It could be a
       *                   file with the following extensions:
       *                  * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/)
```

Review comment:
As mentioned in the issue, there are several "read..." functions including generic `readNet()` dispatcher. Half-baked implementation for just one case would confuse our users. Probably we don't want this. There is strong recommendation to follow `readFromModelOptimizer()` approach and create dedicated API for this feature.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #21066: Native ONNX to Inference Engine backend
**Review Line:** 1073

**Code Changes:**
```diff
@@ -1070,7 +1070,7 @@ CV__DNN_INLINE_NS_BEGIN
      *  backend.
      */
     CV_EXPORTS_W
-    Net readNetFromModelOptimizer(const String &xml, const String &bin);
+    Net readNetFromModelOptimizer(const String &xml, const String &bin = "");
 
     /** @brief Load a network from Intel's Model Optimizer intermediate representation.
      *  @param[in] bufferModelConfig Buffer contains XML configuration with network's topology.
```

Review comment:
`= String()` / `std::string()` to avoid processing of unnecessary extra buffers (other APIs have similar problem so it is better to resolve that in a separate PR)
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Please do not forget to open a pull request to https://github.com/opencv/opencv_extra/ with the same branch name: `GSoC_Support_GatherElements_ONNX`
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -179,6 +179,7 @@ class ONNXImporter
     void parseCast                 (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseConstantFill         (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseGather               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseGatherElements       (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseConcat               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseResize               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseUpsample             (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -2553,6 +2554,53 @@ void ONNXImporter::parseGather(LayerParams& layerParams, const opencv_onnx::Node
     addLayer(layerParams, node_proto);
```

Review comment:
unused variable
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
`Functor` is not needed.
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
There is no reduction operations in `GatherElements`. So we most likely do not need this dispatcher.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -179,6 +179,7 @@ class ONNXImporter
     void parseCast                 (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseConstantFill         (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseGather               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseGatherElements       (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseConcat               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseResize               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseUpsample             (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -2553,6 +2554,53 @@ void ONNXImporter::parseGather(LayerParams& layerParams, const opencv_onnx::Node
     addLayer(layerParams, node_proto);
```

Review comment:
Removed it in the new commit!
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
removed it in the second commit
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
done: https://github.com/opencv/opencv_extra/pull/1082
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
I reverted to the first commit since it was working correctly and passed the tests. Essentially, I edited the dispatcher from the original implementation of scatter, and this dispatcher essentially just calls forward_impl<T>(). I decided to keep the dispatchers just to account for the data type of the output and since they were in harmony with the rest of the implementation in terms of the use of the template.
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
The functor used is just ` auto rd = [](const T& a, const T& b) { return b; }; ` This is different from the original implementation of Scatter, where there are different functors. Once again, I decided to keep it to avoid missing with data types and templates.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements
**Review Line:** 2560

**Code Changes:**
```diff
 }
 
+void ONNXImporter::parseGatherElements(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto)
+{
+    CV_CheckEQ(node_proto.input_size(), 2, "GatherElements: two inputs are required");
+
+    size_t num_const = 0;
+    for (size_t i = 0; i < node_proto.input_size(); ++i){
+        if (constBlobs.find(node_proto.input(i)) != constBlobs.end())
+            ++num_const;
+    }
```

Review comment:
Add a check here to check whether `indices` are provided as constant since the implementation relies on that: ```cpp CV_CheckTrue(constBlobs.find(node_proto.input(1)) != constBlobs.end(), "DNN/ONNX-GatherElements: indices must be constant"; ```
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
Extra calls consume extra time. We should try to save time, especially when it's inference. You can try something like this: ```cpp template<typename T> void forward_impl(const Mat& data, const Mat& indices, Mat& out) { // ... for (size_t i = 0; i < total; i++) { *tmp_p_out = *tmp_p_data; } } template<typename... Args> inline void typeDispatch(const int type, Args&&... args) { switch (type) { case CV_8U: forward_impl<uint8_t>(std::forward<Args>(args)...); break; case CV_32S: forward_impl<int32_t>(std::forward<Args>(args)...); break; case CV_32F: forward_impl<float>(std::forward<Args>(args)...); break; default: CV_Error(cv::Error::BadDepth, "DNN/GatherElements: Unsupported type."); }; } ```
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Could you also add a accuracy test here to test the raft model? Before this, you need to put your changes from https://github.com/opencv/opencv_extra/pull/1085 to https://github.com/opencv/opencv_extra/pull/1082 so that our CI system can detect the changes and then run the tests.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Change `required` to false before the test run. This is needed for large models tests to optionally skip it if there is no file on the CI: ```cpp required = false; testONNXModels("RAFT", npy, 0, 0, false, true, 2); ```
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
sounds like a bug here
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Forward model only once and request both outputs
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
It may be feasible, but the model may be sensitive to the input shape. The intention was we use the model in opencv_zoo for accuracy or performance testing. If the model is shape-sensitive in the end, we have to replace the model in the zoo with one with a smaller input shape. That could be some trouble.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Can you please reduce precision to FP16? Some changes in `blobFromNPY` will be required.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
I will handle this problem after we can run this model. Currently we are facing some other issues running this model.
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
We need to refactor this implementation because it is just tooooooo slow, leading to a very long inference with the RAFT model (it has **160!!!** GatherElements operators). Perf with `GatherElements(data:FLOAT[2700, 1, 2914], indices:INT64[2700, 1, 81])`: [ort_benchmark.zip](https://github.com/opencv/opencv/files/12837145/ort_benchmark.zip) | this impl | ort | | - | - | | 15415.07 ms | 0.15ms |
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
How about we just check the smaller output? This model has two outputs, one of which has shape [1, 2, 45, 60] and file size 21KB, the other of which has shape [1, 2, 360, 480] and file size 1.32MB. The bigger output is calculated from the smaller output. I think it also makes sense if we just check the smaller one. In this case, we can avoid replacing models.
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** added
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+// 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"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
```

Review comment:
Improvement: Previous impl by Aser: 15415.07 ms After removing meaningless for loop: 1ms Speedup: 0.49ms ort: 0.15 ms
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
I found that even though problems of `GatherElements` have been fixed, the inference results of RAFT between ours and onnxruntime are different. Need an investigation into this problem.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
> I found that even though problems of `GatherElements` have been fixed, the inference results of RAFT between ours and onnxruntime are different. Need an investigation into this problem. I found we have different results on the InstanceNorm layer from ONNX Runtime. Let me fix it.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Below is the internal output difference of a node in the model. The final outputs are still very different: ``` ./opencv/modules/dnn/test/test_common.impl.hpp:76: Failure Expected: (normL1) <= (l1), actual: 0.0965853 vs 1e-05 |ref| = 0.47372817993164062 ./opencv/modules/dnn/test/test_common.impl.hpp:79: Failure Expected: (normInf) <= (lInf), actual: 0.474318 vs 0.0001 |ref| = 0.47372817993164062 ./opencv/modules/dnn/test/test_common.impl.hpp:76: Failure Expected: (normL1) <= (l1), actual: 0.581241 vs 1e-05 |ref| = 3.5230345726013184 ./opencv/modules/dnn/test/test_common.impl.hpp:79: Failure Expected: (normInf) <= (lInf), actual: 4.38871 vs 0.0001 |ref| = 3.5230345726013184 ``` --- With https://github.com/opencv/opencv/pull/24378, the difference is reduced to ``` [ RUN ] Test_ONNX_layers.RAFT/0, where GetParam() = OCV/CPU /Users/fengyuantao/Workspace/fytao/projects/gsoc_optical_flow/opencv/modules/dnn/test/test_common.impl.hpp:76: Failure Expected: (normL1) <= (l1), actual: 0.00010332 vs 1e-05 |ref| = 410.04229736328125 /Users/fengyuantao/Workspace/fytao/projects/gsoc_optical_flow/opencv/modules/dnn/test/test_common.impl.hpp:79: Failure Expected: (normInf) <= (lInf), actual: 0.00147033 vs 0.0001 |ref| = 410.04229736328125 [ FAILED ] Test_ONNX_layers.RAFT/0, where GetParam() = OCV/CPU (1738 ms) [----------] 1 test from Test_ONNX_layers (1738 ms total) ``` Still need a further investigation.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24092: GSoC Add ONNX Support for GatherElements

**Code Changes:**
```diff
@@ -9,6 +9,7 @@
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
+#include <numeric>
 namespace opencv_test { namespace {
 
 template<typename TString>
@@ -2129,6 +2130,34 @@ TEST_P(Test_ONNX_nets, Alexnet)
     expectNoFallbacksFromIE(net);
```

Review comment:
Seems good, as for me. l1=2e-4 and lInf=2e-3