nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #23897: dnn: add gemm_layer in place of fully_connected_layer for onnx models
**Review Line:** 12

**Code Changes:**
```diff
@@ -9,6 +9,7 @@ ocv_add_dispatched_file_force_all("int8layers/layers_common" AVX2 AVX512_SKX LAS
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_block" AVX AVX2)
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_depthwise" AVX AVX2 RVV LASX)
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_winograd_f63" AVX AVX2)
+ocv_add_dispatched_file_force_all("layers/cpu_kernels/fast_gemm_kernels" AVX AVX2 NEON LASX)
 
 ocv_add_module(dnn opencv_core opencv_imgproc WRAP python java objc js)
 
```

Review comment:
> NEON We usually don't use runtime dispatching with NEON (it doesn't work due to different ABI). Whole library is compiled with NEON instead.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #23897: dnn: add gemm_layer in place of fully_connected_layer for onnx models
**Review Line:** 2600

**Code Changes:**
```diff
@@ -2597,6 +2597,40 @@ TEST_P(Test_ONNX_layers, where_node)
     testONNXModels("where_layer");
 }
 
+TEST_P(Test_ONNX_layers, Conformance_Gemm_all_attributes) {
+    testONNXModels("test_gemm_all_attributes", pb, 0, 0, false, true, 2);
+}
+TEST_P(Test_ONNX_layers, Conformance_Gemm_alpha) {
+    testONNXModels("test_gemm_alpha", pb, 0, 0, false, true, 2);
+}
```

Review comment:
> Conformance That confuses in test logs. Avoid using `conformance` wording outside of `test_onnx_conformance.cpp`
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #23897: dnn: add gemm_layer in place of fully_connected_layer for onnx models
**Review Line:** 12

**Code Changes:**
```diff
@@ -9,6 +9,7 @@ ocv_add_dispatched_file_force_all("int8layers/layers_common" AVX2 AVX512_SKX LAS
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_block" AVX AVX2)
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_depthwise" AVX AVX2 RVV LASX)
 ocv_add_dispatched_file_force_all("layers/cpu_kernels/conv_winograd_f63" AVX AVX2)
+ocv_add_dispatched_file_force_all("layers/cpu_kernels/fast_gemm_kernels" AVX AVX2 NEON LASX)
 
 ocv_add_module(dnn opencv_core opencv_imgproc WRAP python java objc js)
 
```

Review comment:
Fixing via https://github.com/opencv/opencv/pull/24315
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #23897: dnn: add gemm_layer in place of fully_connected_layer for onnx models
**Review Line:** 2600

**Code Changes:**
```diff
@@ -2597,6 +2597,40 @@ TEST_P(Test_ONNX_layers, where_node)
     testONNXModels("where_layer");
 }
 
+TEST_P(Test_ONNX_layers, Conformance_Gemm_all_attributes) {
+    testONNXModels("test_gemm_all_attributes", pb, 0, 0, false, true, 2);
+}
+TEST_P(Test_ONNX_layers, Conformance_Gemm_alpha) {
+    testONNXModels("test_gemm_alpha", pb, 0, 0, false, true, 2);
+}
```

Review comment:
Fixing via https://github.com/opencv/opencv/pull/24315
**File:** modules/dnn/include/opencv2/dnn/version.hpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 9

**Code Changes:**
```diff
@@ -6,7 +6,7 @@
 #define OPENCV_DNN_VERSION_HPP
 
 /// Use with major OpenCV version only.
-#define OPENCV_DNN_API_VERSION 20230620
+#define OPENCV_DNN_API_VERSION 20231225
 
 #if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS
 #define CV__DNN_INLINE_NS __CV_CAT(dnn5_v, OPENCV_DNN_API_VERSION)
```

Review comment:
> abi-complience-checker That result is ignored on 5.x branch
**File:** modules/3d/include/opencv2/3d.hpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...

**Code Changes:**
```diff
@@ -828,7 +828,7 @@ and a rotation matrix.
 It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
 degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
 sequence of rotations about the three principal axes that results in the same orientation of an
-object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+object, e.g. see @cite Slabaugh . Returned three rotation matrices and corresponding three Euler angles
 are only one of the possible solutions.
  */
 CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ,
@@ -854,7 +854,7 @@ matrix and the position of a camera.
```

Review comment:
Why? There are no such changes on 4.x: https://github.com/opencv/opencv/blame/4.9.0/modules/calib3d/include/opencv2/calib3d.hpp#L2739
**File:** modules/3d/include/opencv2/3d.hpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...

**Code Changes:**
```diff
@@ -828,7 +828,7 @@ and a rotation matrix.
 It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
 degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
 sequence of rotations about the three principal axes that results in the same orientation of an
-object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+object, e.g. see @cite Slabaugh . Returned three rotation matrices and corresponding three Euler angles
 are only one of the possible solutions.
  */
 CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ,
@@ -854,7 +854,7 @@ matrix and the position of a camera.
```

Review comment:
wrong again List of changes on 4.x branch is here: ``` git diff 5.x-merge-4.x-origin..4.9.0 -- modules/calib3d/include/opencv2/calib3d.hpp ```
**File:** modules/calib/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 75

**Code Changes:**
```diff
 \************************************************************************************/
@@ -72,6 +72,7 @@
 #include "precomp.hpp"
 #include "circlesgrid.hpp"
 #include "opencv2/imgproc/imgproc_c.h"
+#include "opencv2/flann.hpp"
 
 #include <stack>
 
@@ -240,7 +241,7 @@ class ChessBoardDetector
 
```

Review comment:
BTW, there is no `_c.h` file even in 4.x: https://github.com/opencv/opencv/blob/4.9.0/modules/calib3d/src/calibinit.cpp#L74
**File:** modules/core/perf/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 3

**Code Changes:**
```diff
@@ -1,6 +1,6 @@
 #include "perf_precomp.hpp"
-#include "opencv2/core/softfloat.hpp"
 #include <numeric>
+#include "opencv2/core/softfloat.hpp"
 
 namespace opencv_test
 {
@@ -452,7 +452,6 @@ INSTANTIATE_TEST_CASE_P(/*nothing*/ , BinaryOpTest,
     )
```

Review comment:
Looks like unnecessary changes in this file. As there are dedicated PRs to 4.x and 5.x - all questions to the author why do we have these differences.
**File:** modules/dnn/perf/perf_layer.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 798

**Code Changes:**
```diff
+
+PERF_TEST_P_(Layer_Attention, VisionTransformer) {
+    test_layer({1, 197, 768}, {768, 768, 768}, 12);
+}
+
+INSTANTIATE_TEST_CASE_P(/**/, Layer_Slice, dnnBackendsAndTargets(false, false));
 INSTANTIATE_TEST_CASE_P(/**/, Layer_NaryEltwise, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU)));
 #ifdef HAVE_CUDA
 INSTANTIATE_TEST_CASE_P(CUDA, Layer_NaryEltwise, testing::Values(std::make_tuple(DNN_BACKEND_CUDA, DNN_TARGET_CUDA)));
@@ -693,6 +805,8 @@ INSTANTIATE_TEST_CASE_P(/**/, Layer_ScatterND, testing::Values(std::make_tuple(D
 INSTANTIATE_TEST_CASE_P(/**/, Layer_LayerNorm, testing::Values(std::make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU)));
```

Review comment:
Don't change exited 5.x code: ```.diff -INSTANTIATE_TEST_CASE_P(/**/, Layer_Slice, dnnBackendsAndTargets(false, false)); +INSTANTIATE_TEST_CASE_P(/**/, Layer_Slice, dnnBackendsAndTargets(/* withInferenceEngine = */false, /* obsolete_withHalide = */false)); ```
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 113

**Code Changes:**
```diff
     processNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt", cv::Size(227, 227));
@@ -111,6 +110,8 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h)
 
 PERF_TEST_P_(DNNTestNetwork, SSD)
 {
+    applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG);
+
     processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", "dnn/ssd_vgg16.prototxt", cv::Size(300, 300));
 }
 
@@ -136,6 +137,8 @@ PERF_TEST_P_(DNNTestNetwork, DenseNet_121)
```

Review comment:
empty line after that https://github.com/opencv/opencv/blob/4.9.0/modules/dnn/perf/perf_net.cpp#L144 to avoid merge conflicts in the future:
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 160

**Code Changes:**
```diff
 {
+    applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG);
+
     processNet("dnn/ssd_inception_v2_coco_2017_11_17.pb", "ssd_inception_v2_coco_2017_11_17.pbtxt", cv::Size(300, 300));
 }
 
 PERF_TEST_P_(DNNTestNetwork, YOLOv3)
 {
-    applyTestTag(CV_TEST_TAG_MEMORY_2GB);
+    applyTestTag(
+        CV_TEST_TAG_MEMORY_2GB,
```

Review comment:
Lost changes for `Inception_v2_SSD_TensorFlow`: https://github.com/opencv/opencv/blame/4.9.0/modules/dnn/perf/perf_net.cpp#L216
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 352

**Code Changes:**
```diff
     randu(inp1, 0.0f, 1.0f);
     randu(inp2, 0.0f, 1.0f);
     inp1 = blobFromImage(inp1, 1.0, Size(), Scalar(), false);
     inp2 = blobFromImage(inp2, 1.0, Size(), Scalar(), false);
-    processNet("", "dnn/onnx/models/vitTracker.onnx", {std::make_tuple(inp1, "template"), std::make_tuple(inp2, "search")});
+    processNet("", "dnn/onnx/models/object_tracking_vittrack_2023sep.onnx", {std::make_tuple(inp1, "template"), std::make_tuple(inp2, "search")});
 }
 
-
 PERF_TEST_P_(DNNTestNetwork, EfficientDet_int8)
 {
```

Review comment:
Need to change test name too: https://github.com/opencv/opencv/blame/4.9.0/modules/dnn/perf/perf_net.cpp#L419-L419C41
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #24862: 5.x merge 4.x - The PR includes all changes in 4.x till 4.9.0 release. OpenCV Contrib PR: https://github.com/opencv/opencv_contrib/pull/362...
**Review Line:** 374

**Code Changes:**
```diff
+
+    processNet("", "dnn/onnx/models/vit_b_32.onnx", cv::Size(224, 224));
+}
+
 INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork, dnnBackendsAndTargets());
 
 } // namespace
```

Review comment:
File changes mismatch: ```.diff @@ -111,6 +111,7 @@ PERF_TEST_P_(DNNTestNetwork, Inception_5h) PERF_TEST_P_(DNNTestNetwork, SSD) { applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG); + processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", "dnn/ssd_vgg16.prototxt", cv::Size(300, 300)); } @@ -152,6 +153,8 @@ PERF_TEST_P_(DNNTestNetwork, opencv_face_detector) PERF_TEST_P_(DNNTestNetwork, Inception_v2_SSD_TensorFlow) { + applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG); + processNet("dnn/ssd_inception_v2_coco_2017_11_17.pb", "ssd_inception_v2_coco_2017_11_17.pbtxt", cv::Size(300, 300)); } @@ -339,7 +342,7 @@ PERF_TEST_P_(DNNTestNetwork, CRNN) { processNet("", "dnn/text_recognition_CRNN_EN_2021sep.onnx", inp); } -PERF_TEST_P_(DNNTestNetwork, ViTTrack) { +PERF_TEST_P_(DNNTestNetwork, VitTrack) { Mat inp1(cv::Size(128, 128), CV_32FC3); Mat inp2(cv::Size(256, 256), CV_32FC3); randu(inp1, 0.0f, 1.0f); ```
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #25120: Fixed ReduceMean layer behaviour
**Review Line:** 1826

**Code Changes:**
```diff
+
+        net.addLayerToPrev(lp.name, lp.type, lp);
+        net.setInput(inpInitA);
+        net.setPreferableBackend(DNN_BACKEND_OPENCV);
+
+        Mat output = net.forward();
+        MatShape gt_shape;
+        for (int j = 0; j < szData.size(); j++)
+        {
+            if (i == j) continue;
+            gt_shape.push_back(szData[j]);
```

Review comment:
I cannot understand what the test actually does. Why `forward()` is called in a loop, if the network parameters and input is not changed?
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #25120: Fixed ReduceMean layer behaviour
**Review Line:** 1826

**Code Changes:**
```diff
+
+        net.addLayerToPrev(lp.name, lp.type, lp);
+        net.setInput(inpInitA);
+        net.setPreferableBackend(DNN_BACKEND_OPENCV);
+
+        Mat output = net.forward();
+        MatShape gt_shape;
+        for (int j = 0; j < szData.size(); j++)
+        {
+            if (i == j) continue;
+            gt_shape.push_back(szData[j]);
```

Review comment:
I changed axes parameter https://github.com/opencv/opencv/blob/c96dd8be93e5627ad30a96b27a85f514bdda85b1/modules/dnn/test/test_layers.cpp#L1814
**File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #24724: build: suppress warning ARM64 + Visual Studio build
**Review Line:** 1645

**Code Changes:**
```diff
@@ -1642,7 +1642,7 @@ inline int v_signmask(const v_uint64x2& a)
 #if CV_NEON_AARCH64
     const int64x2_t signPosition = {0,1};
     uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), signPosition);
-    uint64_t t0 = vaddvq_u64(v0);
+    int t0 = (int)vaddvq_u64(v0);
     return t0;
 #else // #if CV_NEON_AARCH64
     int64x1_t m0 = vdup_n_s64(0);
```

Review comment:
I was able to cross compile for ARM64 Windows and can reproduce only this warning (MS VS 2022). I propose to revert other changes and merge the PR for now.
**File:** modules/dnn/src/net_impl.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...
**Review Line:** 525

**Code Changes:**
```diff
@@ -186,11 +186,6 @@ void Net::Impl::setUpNet(const std::vector<LayerPin>& blobsToKeep_)
 
         clear();
 
-        if (hasDynamicShapes)
-        {
-            updateLayersShapes();
-        }
-
         this->blobsToKeep = blobsToKeep_;
 
         allocateLayers(blobsToKeep_);
@@ -475,7 +470,7 @@ void Net::Impl::allocateLayer(int lid, const LayersShapesMap& layersShapes)
         allocateLayer(*i, layersShapes);
 
```

Review comment:
Moved it to line 590, because this line runs after type inferense and line 590 runs before type inference
**File:** modules/dnn/src/layers/const_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -57,6 +57,20 @@ class ConstLayerImpl CV_FINAL : public ConstLayer
         return false;
     }
 
+    void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
`type` or `depth`?
**File:** modules/dnn/src/legacy_backend.hpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -237,6 +237,10 @@ struct BlobManager
 
         const ShapesVec &outShapes = layerShapes.out,
                         internalShapes = layerShapes.internal;
+        const TypesVec &outTypes = layerShapes.outTypes,
+                       &internalTypes = layerShapes.internalTypes;
+        CV_CheckEQ(outShapes.size(), outTypes.size(), "Numbers shapes and types shoud be equal");
+        CV_CheckEQ(internalShapes.size(), internalTypes.size(), "Numbers shapes and types shoud be equal");
 
         outputBlobs.resize(std::max((size_t)1, outShapes.size()));  // layer produce at least one output blob
```

Review comment:
Please use `CV_CheckType`
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -62,6 +62,7 @@ CV__DNN_INLINE_NS_BEGIN
 //! @{
 
     typedef std::vector<int> MatShape;
+    typedef int MatType;
 
     /**
      * @brief Enum of computation backends supported by layers.
@@ -205,8 +206,16 @@ CV__DNN_INLINE_NS_BEGIN
          */
```

Review comment:
Why type is requires to get only shapes?
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -62,6 +62,7 @@ CV__DNN_INLINE_NS_BEGIN
 //! @{
 
     typedef std::vector<int> MatShape;
+    typedef int MatType;
 
     /**
      * @brief Enum of computation backends supported by layers.
@@ -205,8 +206,16 @@ CV__DNN_INLINE_NS_BEGIN
          */
```

Review comment:
Since the shape inference and the type inference has the same pipeline, I added the type inference into the shape inference pipeline. So this function probably will be renamed into getLayersShapesAndTypes
**File:** modules/dnn/src/layers/const_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -57,6 +57,20 @@ class ConstLayerImpl CV_FINAL : public ConstLayer
         return false;
     }
 
+    void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
Depth. I will replace it with depth()
**File:** modules/dnn/src/layers/concat_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -115,6 +115,19 @@ class ConcatLayerImpl CV_FINAL : public ConcatLayer
         return false;
     }
 
+    virtual  void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
CV_16S -> CV_16F See https://github.com/opencv/opencv/pull/24892
**File:** modules/dnn/src/layers/const_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -57,6 +57,20 @@ class ConstLayerImpl CV_FINAL : public ConstLayer
         return false;
     }
 
+    void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
CV_16S -> CV_16F. See https://github.com/opencv/opencv/pull/24892
**File:** modules/dnn/src/layers/gather_elements_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -57,6 +57,18 @@ class GatherElementsLayerImpl CV_FINAL : public GatherElementsLayer
         return false;
     }
 
+    virtual  void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
The same for CV_16F
**File:** modules/dnn/src/layers/permute_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -178,6 +178,24 @@ class PermuteLayerImpl CV_FINAL : public PermuteLayer
         return false;
     }
 
+    void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
CV_16S -> CV_16F
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...
**Review Line:** 413

**Code Changes:**
```diff
 
+        virtual void getTypes(const std::vector<MatType>& inputs,
+                              const int requiredOutputs,
+                              const int requiredInternals,
+                              std::vector<MatType>&outputs,
+                              std::vector<MatType>&internals) const;
+
         virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
                                const std::vector<MatShape> &outputs) const {CV_UNUSED(inputs); CV_UNUSED(outputs); return 0;}
 
@@ -675,56 +690,67 @@ CV__DNN_INLINE_NS_BEGIN
```

Review comment:
Do we really need such kind of functionality in public API? What Users scenarios need all types of all layers at once? It makes sense to support this scenarios instead: - user set network inputs - user specify list of requested outputs - network compiles (internally calls layer's `.finalize()`) - user asks for layer by its name - ask types and shapes of layer outputs without passing of any parameters like "inputs/outputs/internals" - pass only index of layer's output. Note: - support multiple outputs per layer - user should not know anything about "internals" - `getMemoryShapes` / `getLayersShapes()` should be deprecated as primary API too
**File:** modules/dnn/src/layers/gather_layer.cpp
**Change Type:** modified
**Context:** PR #24411: Added int32, int64 support and type inference to dnn - Related PRs: - Contrib: https://github.com/opencv/opencv_contrib/pull/3648 - Extra: ...

**Code Changes:**
```diff
@@ -40,6 +40,19 @@ class GatherLayerImpl CV_FINAL : public GatherLayer
         return false;
     }
 
+    virtual  void getTypes(const std::vector<MatType>& inputs,
+        const int requiredOutputs,
+        const int requiredInternals,
+        std::vector<MatType>& outputs,
+        std::vector<MatType>& internals) const CV_OVERRIDE
+    {
```

Review comment:
Use `CV_Check*` macros instead of `CV_Assert()`.