nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
`CV_Assert`
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 678

**Code Changes:**
```diff
+                "Provided output subscript does not include ellipsis while Inputs subscrits constain ellipsis");
+            } else {
+                CV_Error(Error::StsNotImplemented, "Ellipsis are not yet supported");
+            }
+        }
+    }
+}
+
+void LayerEinsumImpl::processBroadcastedDims()
+{
+    // Only compute this function if ellipsis "..." was found in the equation
```

Review comment:
I propose to raise not implemented exception on else branch to catch errors easier.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 687

**Code Changes:**
```diff
+{
+    // Only compute this function if ellipsis "..." was found in the equation
+    if (numOfEllipsisDims > 0){
+        // add assert inplace of return bool
+        CV_Error(Error::StsError, "Ellipsis are not supperted currenly");
+    }
+}
+
+
+
+void LayerEinsumImpl::processEquation(const std::vector<MatShape>& inputs)
```

Review comment:
What of `numOfEllipsisDims <=0` ?
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
CV_Assert with 2 conditions.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 791

**Code Changes:**
```diff
+    const Mat& candidateOutput,
+    const MatShape& ordered_subscript_indices_in_candidate)
+{
+    const std::vector<int>& subscript_indices_to_output_indices = subscriptIndicesToOutputIndices;
+    const auto output_dims = einsumOutDims;
+
+    MatShape output_shape = output_dims;
+    const auto output_rank = output_dims.size();
+
+    // CV_CheckEQ((int) candidateOutput.dims,  (int) output_shape.size(),
+    //           "Einsum op: The candidate output cannot be reshaped into the op's output");
```

Review comment:
Extra space line.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
I propose to remove `outputSize` field and move assert to constructor.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 327

**Code Changes:**
```diff
+        String equation = params.get<String>("equation");
+        int outputSize = params.get<int>("outputSize");
+        numInputs  = params.get<int>("inputSize");
+
+        CV_CheckEQ(outputSize, 1, "Einsum layer should only have one output");
+
+        // get the input shapes from onnx importer
+        for (int i=0; i < numInputs; i++){
+            auto param = params.get("inputShapes" + cv::format("%d", i));
+            int inputDims = param.size();
+            std::vector<int> shape;
```

Review comment:
Extra empty line.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 370

**Code Changes:**
```diff
+
+    // getMeoryShapes
+    bool getMemoryShapes(const std::vector<MatShape> &inputs,
+                         const int requiredOutputs,
+                         std::vector<MatShape> &outputs,
+                         std::vector<MatShape> &internals) const CV_OVERRIDE
+    {
+        CV_UNUSED(internals);
+
+        // check if passed and parsed inputs match up in number and dimensions
+        CV_CheckEQ(static_cast<int>(inputs.size()), numInputs,
```

Review comment:
`internals` is not used in the method. please add `CV_UNUSED(internals);` as first line to the method to suppress it.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 756

**Code Changes:**
```diff
+                    if (subscriptIndicesToDimValue[mappedIndx] != dimValue)
+                    {
+                        if(subscriptIndicesToDimValue[mappedIndx] == 1){
+                            //TODO: uncomment later on
+                            // subscriptIndicesToDimValue[mappedIndx] == dimValue;
+                        } else
+                        {
+                            if (dimValue != 1)
+                            {
+                                CV_Error(Error::StsError, cv::format("Einsum operands can not be broadcasted."
+                                                                     "Check input shapes/equation passed."
```

Review comment:
Is it still relevant? I propose to refactor condition, if not.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -1415,6 +1415,56 @@ TEST_P(Test_ONNX_layers, LSTM_layout_batch)
     testONNXModels("lstm_layout_1", npy, 0.005, 0.005, false, false, 3);
 }
 
+TEST_P(Test_ONNX_layers, DISABLED_Einsum_1D)
+{
+    testONNXModels("einsum_1d", npy, 0, 0, false, false, 2);
+}
+
+TEST_P(Test_ONNX_layers, Einsum_2D)
```

Review comment:
We don't need to SKIP because fallback to CPU code should work by default
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
use `static_cast<int>('z')` instead of 26
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 180

**Code Changes:**
```diff
+    MatShape tmp_perm;
+    tmp_perm.reserve(permutation.size());
+    for (int i = 0; i < permutation.size(); i++)
+        tmp_perm.emplace_back(static_cast<int>(permutation[i]));
+
+    cv::transposeND((reshape ? input_reshaped : input), tmp_perm, output);
+    return output;
+}
+
+
+bool IsTransposeRequired(size_t input_rank, const std::vector<size_t>& permutation) {
```

Review comment:
Can we replace to Permute layer similar to `reduceSum`?
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 550

**Code Changes:**
```diff
+        for (const auto& subscriptIndex : currSubscriptIndices)
+        {
+            if(subscriptIndicesToInputIndex[subscriptIndex] == -1){
+                subscriptIndicesToInputIndex[subscriptIndex] = dimIndexInIreprocessedInput++;
+                homogenizedInputDims_[subscriptIndex] = input_dims[dimIndexInOriginalInput];
+            } else {
+                // Call diagonal
+                preprocessed = Diagonal(
+                    !preprocessed.empty() ? preprocessed : inputs[inputIter],
+                    subscriptIndicesToInputIndex[subscriptIndex],
+                    dimIndexInIreprocessedInput);
```

Review comment:
Mix of the code block start indentation.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Can be simplified like this: ```cpp std::stringstream src(lhs_eq); for (std::string token; std::getline(src, token',');) { lhs_eq_tokens.emplace_back(token); } ```
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Is that a required reference?
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Please do not use `&&` inside CV_Assert. There are more informative alternatives: ```cpp CV_CheckNE(letterIndex, -1, "The only permissible subscript labels are lowercase letters (a-z) and uppercase letters (A-Z)."); CV_CheckEQ(outputLetterToCount[letterIndex], 0, "Output subscript constains repeated letters"); ``` ``` C++ exception with description "OpenCV(4.8.0-dev) /home/dkurt/opencv/modules/objdetect/src/qrcode.cpp:2839: error: (-2:Unspecified error) in function 'void cv::errorCorrection(std::vector<unsigned char>&, int, int)' > The only permissible subscript labels are lowercase letters (a-z) and uppercase letters (A-Z). (expected: 'letterIndex != -1'), where > 'letterIndex' is -1 > must be not equal to > '-1' is -1 " thrown in the test body. ```
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Even better `CV_CheckNE(mappedIndex, -1, "Output subscript has letters that were not encountered in the inputs");`
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Let's keep them uninitialized `std::vector<MatShape> outputShapes, internalShapes;`
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
As we ignore `internalShapes`, why to create an empty Mat?
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Will it work with `Mat output(outputShapes[0], CV_32F)`?
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
redundant space.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -194,6 +194,7 @@ class ONNXImporter
     void parseTile                 (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseLayerNorm            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSimpleLayers         (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseEinsum               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
 
     // Domain: com.microsoft
     // URL: https://github.com/microsoft/onnxruntime/blob/master/docs/ContribOperators.md
@@ -3338,6 +3339,40 @@ void ONNXImporter::parseSimpleLayers(LayerParams& layerParams, const opencv_onnx
     addLayer(layerParams, node_proto);
```

Review comment:
```cpp CV_CheckFalse(einsumInpShapes.empty(), "ERROR no inputs shapes"); for (int i = 0; i < einsumInpShapes.size(); i++) { layerParams.set("inputShapes" + cv::format("%d", i), DictValue::arrayInt(einsumInpShapes[i].begin(), einsumInpShapes[i].size())); } ```
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -194,6 +194,7 @@ class ONNXImporter
     void parseTile                 (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseLayerNorm            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSimpleLayers         (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseEinsum               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
 
     // Domain: com.microsoft
     // URL: https://github.com/microsoft/onnxruntime/blob/master/docs/ContribOperators.md
@@ -3338,6 +3339,40 @@ void ONNXImporter::parseSimpleLayers(LayerParams& layerParams, const opencv_onnx
     addLayer(layerParams, node_proto);
```

Review comment:
CV_CheckFalse
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Need proper indentation
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
use CV_CheckEQ
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Use CV_CheckEQ
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 380

**Code Changes:**
```diff
+        CV_CheckEQ(static_cast<int>(inputs.size()), numInputs,
+            "Number of inputs in forward and inputs during graph constructions do not match");
+        for (int i = 0; i < numInputs; i++)
+        {
+            if (inputs[i] != einsumInpShapes[i])
+                CV_Error(Error::StsAssert, "Passed input shapes do not match with parsed input shapes!");
+        }
+
+        outputs.clear();
+        outputs.emplace_back(einsumOutDims);
+        return true;
```

Review comment:
Use CV_CheckEQ
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 632

**Code Changes:**
```diff
+    for (auto letter : rhs_eq)
+    {
+        if(letter == '.')
+        {
+            CV_Error(Error::StsNotImplemented, "Ellipsis are not supported yet");
+        } else {
+            CV_CheckEQ(middleOfEllipsis, false,
+                "Encountered '.' character that is not part of output subscript");
+
+            auto letterIndex = letterToIndex(letter);
+
```

Review comment:
You can use `CV_CheckNE(letter, static_cast<int>('.'), "Ellipsis are not supported yet")` to eliminate the if conditioning here.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
Put a new empty line before end of file.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 756

**Code Changes:**
```diff
+                    if (subscriptIndicesToDimValue[mappedIndx] != dimValue)
+                    {
+                        if(subscriptIndicesToDimValue[mappedIndx] == 1){
+                            //TODO: uncomment later on
+                            // subscriptIndicesToDimValue[mappedIndx] == dimValue;
+                        } else
+                        {
+                            if (dimValue != 1)
+                            {
+                                CV_Error(Error::StsError, cv::format("Einsum operands can not be broadcasted."
+                                                                     "Check input shapes/equation passed."
```

Review comment:
Still relevant.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
`CV_CheckEQ`
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
```cpp size_t matDimSize = left.total() ```
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
```cpp matDimSize = right.total() ```
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer

**Code Changes:**
```diff
@@ -0,0 +1,1114 @@
+// 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 <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
```

Review comment:
```cpp overrideDimSize = total(leftShapeOverride); ```
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 98

**Code Changes:**
```diff
+            Mat part2 = reshapedInput2(ranges2);
+            int shape2[] = {static_cast<int>(K), static_cast<int>(N)};
+            part2 = part2.reshape(1, sizeof(shape2)/sizeof(shape2[0]), shape2);
+
+            Mat tmp_output;
+            cv::gemm(part1, part2, 1.0, cv::Mat(), 1.0, tmp_output);
+            int newShape[] = {1, static_cast<int>(M), static_cast<int>(N)};
+            tmp_output = tmp_output.reshape(1, sizeof(newShape)/sizeof(newShape[0]), newShape);
+
+            output.emplace_back(tmp_output);
+        }
```

Review comment:
Or even entire Gemm layer, without using separate primitives.
**File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** added
**Context:** PR #24037: Add Support for Einsum Layer
**Review Line:** 661

**Code Changes:**
```diff
+            subscriptIndicesToOutputIndices[mappedIndex] = outputDimCounter++;
+        }
+    }
+}
+
+void LayerEinsumImpl::createOutputSubsctipt()
+{
+    // The explicit form requires no operation, as the output
+    // would have already been parsed during the input parsing process.
+    if(explicitEquation)
+    {
```

Review comment:
Method seems useless. Both branches lead to an error.