nareshmlx/opencv-pr huggingface dataset:
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
> `TENGINE_GITHUB_PKG_MD5` > `_GITHUB_` GitHub is misleading here. By design OpenCV may use any servers to download original external code. Some time ago we used sourceforge.net for IPPICV package. Name should be `TENGINE_PKG_ORIGINAL_MD5`
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Done. `__HOST` is eliminated now.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> Unable to recognize git server of OpenCV source code. Done. > Replace WARNING with STATUS to pass CI Done. > Condition I use `if(OPENCV_DOWNLOAD_MIRROR_ID STREQUAL "gitcode" OR OPENCV_DOWNLOAD_MIRROR_ID STREQUAL "custom")` instead. `"github"` is not needed.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
Done. It is indeed a good idea to use `ocv_check_environment_variables`, which I did not know before.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
> ocv_init_download_mirror() Renaming is Done. > EOL before EOF Done.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
`OPENCV_DOWNLOAD_PRE` is used.
**File:** cmake/OpenCVDownload.cmake
**Change Type:** modified
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -37,6 +37,50 @@ file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
 file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
 
+ocv_check_environment_variables(OPENCV_DOWNLOAD_MIRROR_ID)
+
+function(ocv_init_download_mirror)
+  if(NOT DEFINED OPENCV_DOWNLOAD_MIRROR_ID)
+    # Run `git remote get-url origin` to get remote source
+    execute_process(
```

Review comment:
In the latest commit, either "gitcode.cmake" or "custom.cmake" can be added into hooks. So I think it is not necessary to check whether those files exist.
**File:** cmake/mirrors/gitcode.cmake
**Change Type:** added
**Context:** PR #21531: Support downloading 3rdparty resources from Gitcode & Gitlab-style mirrors

**Code Changes:**
```diff
@@ -0,0 +1,70 @@
+# Tengine (Download via commit id)
+ocv_update(TENGINE_PKG_MD5_GITCODE 1b5908632b557275cd6e85b0c03f9690)
+ocv_update(TENGINE_PKG_MD5_ORIGINAL 23f61ebb1dd419f1207d8876496289c5) # same as tengine_md5sum for TENGINE commit of e89cf8870de2ff0a80cfe626c0b52b2a16fb302e
+
+# TBB (Download from release page)
+ocv_update(TBB_RELEASE_GITCODE "v2020.2")
+ocv_update(TBB_PKG_NAME_GITCODE "tbb-${TBB_RELEASE_GITCODE}")
+ocv_update(TBB_PKG_MD5_GITCODE 4eeafdf16a90cb66e39a31c8d6c6804e)
+ocv_update(TBB_PKG_MD5_ORIGINAL 5af6f6c2a24c2043e62e47205e273b1f) # same as OPENCV_TBB_RELEASE_MD5 for TBB release of v2020.2
```

Review comment:
Source is added as suffix to each package-related vars, such as `TENGINE_PKG_MD5_ORIGINAL`.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -122,6 +122,7 @@ class ONNXImporter
     void parseMaxUnpool            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseMaxPool              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseAveragePool          (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseGlobalPool           (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseReduce               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSlice                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSplit                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -1087,7 +1088,7 @@ void ONNXImporter::parseAveragePool(LayerParams& layerParams, const opencv_onnx:
     addLayer(layerParams, node_proto);
```

Review comment:
remove extra spaces (should be just 1) after `!=`
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -122,6 +122,7 @@ class ONNXImporter
     void parseMaxUnpool            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseMaxPool              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseAveragePool          (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseGlobalPool           (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseReduce               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSlice                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSplit                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -1087,7 +1088,7 @@ void ONNXImporter::parseAveragePool(LayerParams& layerParams, const opencv_onnx:
     addLayer(layerParams, node_proto);
```

Review comment:
newline after }
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -122,6 +122,7 @@ class ONNXImporter
     void parseMaxUnpool            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseMaxPool              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseAveragePool          (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseGlobalPool           (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseReduce               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSlice                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSplit                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -1087,7 +1088,7 @@ void ONNXImporter::parseAveragePool(LayerParams& layerParams, const opencv_onnx:
     addLayer(layerParams, node_proto);
```

Review comment:
remove extra spaces after `!=`(should be just one)
**File:** modules/dnn/src/layers/reduce_layer.cpp
**Change Type:** added
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -0,0 +1,388 @@
+// 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/core/hal/intrin.hpp"
+#include "../op_cuda.hpp"
+#include "../op_webnn.hpp"
+
```

Review comment:
Please drop inheritance from functors: https://github.com/alalek/opencv/commit/pr21601_r (with similar change for int8 implementation)
**File:** modules/dnn/src/layers/reduce_layer.cpp
**Change Type:** added
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -0,0 +1,388 @@
+// 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/core/hal/intrin.hpp"
+#include "../op_cuda.hpp"
+#include "../op_webnn.hpp"
+
```

Review comment:
> `hasSIMD` Looks like it is unused. Please remove.
**File:** modules/dnn/include/opencv2/dnn/all_layers.hpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -325,6 +325,20 @@ CV__DNN_INLINE_NS_BEGIN
         static Ptr<PoolingLayerInt8> create(const LayerParams& params);
     };
 
+    class CV_EXPORTS ReduceLayer : public Layer
+    {
+    public:
+        int reduceType;
+        std::vector<size_t> reduceDims;
+        static Ptr<ReduceLayer> create(const LayerParams& params);
```

Review comment:
> deletedDims reductionDims? or something else? Could you please add link to some document, e.g. ONNX specification
**File:** modules/dnn/include/opencv2/dnn/all_layers.hpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -325,6 +325,20 @@ CV__DNN_INLINE_NS_BEGIN
         static Ptr<PoolingLayerInt8> create(const LayerParams& params);
     };
 
+    class CV_EXPORTS ReduceLayer : public Layer
+    {
+    public:
+        int reduceType;
+        std::vector<size_t> reduceDims;
+        static Ptr<ReduceLayer> create(const LayerParams& params);
```

Review comment:
> type `reduce_mode`? (to avoid confusion with data type)
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend
**Review Line:** 1223

**Code Changes:**
```diff
+                shouldDelete[i] = temp;
 
-            node_proto.set_output(0, poolLp.name);
-            addLayer(poolLp, node_proto);
+                std::swap(perm[index], perm[i]);
+                std::swap(inpShape[index], inpShape[i]);
+                needPermuet = true;
+            }
+            else
+                break;
         }
```

Review comment:
Build error from logs: ``` 37>C:\build\precommit_opencl\4.x\opencv\modules\dnn\src\onnx\onnx_importer.cpp(1218,63): error C2665: 'std::swap': none of the 2 overloads could convert all the argument types [C:\build\precommit_opencl\build\modules\dnn\opencv_dnn.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include\thread(200,13): message : could be 'void std::swap(std::thread &,std::thread &) noexcept' (compiling source file C:\build\precommit_opencl\4.x\opencv\modules\dnn\src\onnx\onnx_importer.cpp) [C:\build\precommit_opencl\build\modules\dnn\opencv_dnn.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include\utility(104,19): message : or 'void std::swap<std::_Vb_reference<std::_Wrap_alloc<std::allocator<std::_Vbase>>>,0>(_Ty &,_Ty &) noexcept(<expr>)' [C:\build\precommit_opencl\build\modules\dnn\opencv_dnn.vcxproj] with [ _Ty=std::_Vb_reference<std::_Wrap_alloc<std::allocator<std::_Vbase>>> ] (compiling source file C:\build\precommit_opencl\4.x\opencv\modules\dnn\src\onnx\onnx_importer.cpp) C:\build\precommit_opencl\4.x\opencv\modules\dnn\src\onnx\onnx_importer.cpp(1218,63): message : while trying to match the argument list '(std::_Vb_reference<std::_Wrap_alloc<std::allocator<std::_Vbase>>>, std::_Vb_reference<std::_Wrap_alloc<std::allocator<std::_Vbase>>>)' [C:\build\precommit_opencl\build\modules\dnn\opencv_dnn.vcxproj] ``` Looks like there is no `std::swap()` for elements of `std::vector<bool>` - as there are no elements references.
**File:** modules/dnn/src/int8layers/reduce_layer.cpp
**Change Type:** added
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -0,0 +1,213 @@
+// 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 "layers_common.hpp"
+
+#include <algorithm>
+#include <stdlib.h>
```

Review comment:
We still have `virtual` stuff. It should be dropped as we use templates.
**File:** modules/dnn/src/int8layers/reduce_layer.cpp
**Change Type:** added
**Context:** PR #21601: DNN: Support some reduce layers of ONNX on CPU backend

**Code Changes:**
```diff
@@ -0,0 +1,213 @@
+// 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 "layers_common.hpp"
+
+#include <algorithm>
+#include <stdlib.h>
```

Review comment:
Do we even need base class now?
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -65,6 +65,14 @@ class ONNXImporter
     void expandMid(const std::string& prefix, opencv_onnx::NodeProto& node_proto,
                    const std::string& input, size_t n);
     void addNegation(const LayerParams& layerParams, opencv_onnx::NodeProto& node_proto, int input_id);
+    void lstm_extractConsts(LayerParams& layerParams, const opencv_onnx::NodeProto& lstm_proto, size_t idx, int* blobShape_, int size);
+    void lstm_add_reshape(const std::string& input_name, const std::string& output_name, int* layerShape, size_t n);
+    std::string lstm_add_slice(int index, const std::string& input_name, int* begin, int* end, size_t n);
+    std::string lstm_fix_dims(LayerParams& layerParams, const opencv_onnx::NodeProto& lstm_proto,
+                              int batch_size, int num_directions, int hidden_size, bool need_y, const std::string& y_name,
+                              const int index);
```

Review comment:
I propose to add "lstm" to the method name as soon as the function is implemented for lstm only.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
I propose to add some comment here and in the place of actual usage about the workaround: what does the workaround do and why it's required.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
Extra line is not required here.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
PR is targeted to 3.4 branch, so there is no CUDA in DNN. Is there related PR targeted to 4.x?
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
Yes, there [is](https://github.com/opencv/opencv/pull/20938). In 4.x branch the contents of this vector will be used, but here its purpose is to tell if we need any onnx-related transformations after forward.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
It may be also not a workaround, since it looks like not a bug, but a special memory arrangement. May be `blobsCudaLayout` or `blobsForCudaInference` will suit better.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
Possibly they are `pI, pF, pO` for consistency with gates.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
Looks like this file uses `i++`-style.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -65,6 +65,14 @@ class ONNXImporter
     void expandMid(const std::string& prefix, opencv_onnx::NodeProto& node_proto,
                    const std::string& input, size_t n);
     void addNegation(const LayerParams& layerParams, opencv_onnx::NodeProto& node_proto, int input_id);
+    void lstm_extractConsts(LayerParams& layerParams, const opencv_onnx::NodeProto& lstm_proto, size_t idx, int* blobShape_, int size);
+    void lstm_add_reshape(const std::string& input_name, const std::string& output_name, int* layerShape, size_t n);
+    std::string lstm_add_slice(int index, const std::string& input_name, int* begin, int* end, size_t n);
+    std::string lstm_fix_dims(LayerParams& layerParams, const opencv_onnx::NodeProto& lstm_proto,
+                              int batch_size, int num_directions, int hidden_size, bool need_y, const std::string& y_name,
+                              const int index);
```

Review comment:
Possibly `int* blobShape`.
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
To avoid confusion we need to rename this field (there is no CUDA code in DNN module for 3.4 branch). What is about `originalBlobs` or other more clear name?
**File:** modules/dnn/src/layers/recurrent_layers.cpp
**Change Type:** modified
**Context:** PR #21522: Fix LSTM support in ONNX

**Code Changes:**
```diff
@@ -103,7 +103,7 @@ static ActivationFunction get_activation_function(const String& activation) {
 
 class LSTMLayerImpl CV_FINAL : public LSTMLayer
 {
-    int numTimeStamps, numSamples;
+    int numTimeStamps, numSamples, numHidden;
     bool allocated;
 
     MatShape outTailShape;  //shape of single output sample
@@ -127,6 +127,10 @@ class LSTMLayerImpl CV_FINAL : public LSTMLayer
```

Review comment:
Sure, fixed.