Merge pull request #25100 from LaurentBerger:I25077

Fix issue #25077 #25100

Fixes https://github.com/opencv/opencv/issues/25077

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Laurent Berger 2024-02-27 12:15:11 +01:00 committed by GitHub
parent c04750ab57
commit 3c712cf77d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -547,7 +547,7 @@ public:
MatShape realOutputDims = shape(result); MatShape realOutputDims = shape(result);
size_t realProd = std::accumulate(realOutputDims.begin(), realOutputDims.end(), 1, std::multiplies<int>()); size_t realProd = std::accumulate(realOutputDims.begin(), realOutputDims.end(), 1, std::multiplies<int>());
CV_CheckEQ(reqProd, realProd, "Real output can not be shaped in to requred output"); CV_CheckEQ(reqProd, realProd, "Real output can not be shaped in to required output");
// reduce dimentions // reduce dimentions
result = result.reshape(1, einsumOutDims.size(), einsumOutDims.data()); result = result.reshape(1, einsumOutDims.size(), einsumOutDims.data());
@ -1280,12 +1280,13 @@ Mat LayerEinsumImpl::pairwiseOperandProcess(
// Covered by ExplicitEinsumAsTensorContractionReshapeFinal. // Covered by ExplicitEinsumAsTensorContractionReshapeFinal.
output = output.reshape(1, reshaped_dims.size(), reshaped_dims.data()); output = output.reshape(1, reshaped_dims.size(), reshaped_dims.data());
} }
} else { else {
output = Transpose( output = Transpose(
output, output,
outputDims, outputDims,
outputPermutation); outputPermutation);
} }
}
} else { // This is the final pair - Transpose directly to the output ordering required and copy the contents to the op's output } else { // This is the final pair - Transpose directly to the output ordering required and copy the contents to the op's output
// not sure if this finalize shape is needed at all // not sure if this finalize shape is needed at all
output = FinalizeOutput(output, currentSubscriptOrder); output = FinalizeOutput(output, currentSubscriptOrder);