Add Support for Einsum Layer#24037
Merged
asmorkalov merged 29 commits intoopencv:4.xfrom Sep 22, 2023
Merged
Conversation
dkurt
reviewed
Jul 21, 2023
5 tasks
dkurt
reviewed
Aug 28, 2023
| return true; | ||
| } | ||
|
|
||
| Mat batchwiseMatMul( |
Member
There was a problem hiding this comment.
Can we create an object of FullyConnected layer and use it for inference? For example, Permute layer inside ShuffleChannel
dkurt
reviewed
Aug 28, 2023
fengyuentau
reviewed
Aug 29, 2023
fengyuentau
reviewed
Aug 29, 2023
| 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); |
Member
There was a problem hiding this comment.
You can use the fast_gemm which is introduced in #23897 once it is merged.
Member
There was a problem hiding this comment.
Or even entire Gemm layer, without using separate primitives.
fengyuentau
reviewed
Aug 29, 2023
3608680 to
016c536
Compare
related to cv::fromat()
output dimentions
dkurt
reviewed
Sep 19, 2023
dkurt
reviewed
Sep 19, 2023
dkurt
reviewed
Sep 19, 2023
dkurt
reviewed
Sep 19, 2023
dkurt
reviewed
Sep 19, 2023
dkurt
reviewed
Sep 20, 2023
| } | ||
| } | ||
|
|
||
| void LayerEinsumImpl::createOutputSubsctipt() |
Member
There was a problem hiding this comment.
Method seems useless. Both branches lead to an error.
dkurt
reviewed
Sep 20, 2023
| "Check input shapes/equation passed." | ||
| "Input shape of operand [%d]", inputIdx) + | ||
| cv::format(" is incompatible in the dimention [%zu].", static_cast<size_t>(dim_count))); | ||
| } |
dkurt
reviewed
Sep 20, 2023
dkurt
reviewed
Sep 20, 2023
| currentLeft = reduceSum(tensorToReduce, shapeToReduce); | ||
| } | ||
|
|
||
| } else { |
dkurt
reviewed
Sep 20, 2023
dkurt
reviewed
Sep 20, 2023
| // assuming that we won't encounter any input with a rank greater than 10. | ||
| // In such cases, the value of num_subscript_indices_ would be greater than 10. | ||
| subscriptIndicesToLastInput.reserve(10); | ||
| subscriptIndicesToDimValue.reserve(10); |
Member
There was a problem hiding this comment.
Do we really need this allocation?
dkurt
approved these changes
Sep 22, 2023
dkurt
reviewed
Sep 22, 2023
Member
dkurt
left a comment
There was a problem hiding this comment.
Let's merge. The rest of syntax issues will be solved later. Missed functionality will be adjusted later.
Contributor
|
Several tests don't pass #24311 |
12 tasks
Merged
hanliutong
pushed a commit
to hanliutong/opencv
that referenced
this pull request
Oct 7, 2023
Add Support for Einsum Layer opencv#24037 ### This PR adding support for [Einsum Layer](https://pytorch.org/docs/stable/generated/torch.einsum.html) (in progress). This PR is currently not to be merged but only reviewed. Test cases are located in [opencv#1090](opencv/opencv_extra#1090 in OpenCV extra **DONE**: - [x] 2-5D GMM support added - [x] Matrix transpose support added - [x] Reduction type comupte 'ij->j' - [x] 2nd shape computation - during forward **Next PRs**: - [ ] Broadcasting reduction "...ii ->...i" - [ ] Add lazy shape deduction. "...ij, ...jk->...ik" - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize **Later in 5.x version (requires support for 1D matrices)**: - [ ] Add 1D vector multiplication support - [ ] Inter product "i, i" (problems with 1D shapes) ### 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 - [ ] 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
asmorkalov
pushed a commit
that referenced
this pull request
Oct 24, 2023
Ellipses supported added for Einsum Layer #24322 This PR added addresses issues not covered in #24037. Namely these are: Test case for this patch is in this PR [#1106](opencv/opencv_extra#1106) in opencv extra Added: - [x] Broadcasting reduction "...ii ->...I" - [x] Add lazy shape deduction. "...ij, ...jk->...ik" Features to add: - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize - [ ] Performance test ### 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 - [ ] 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
IskXCr
pushed a commit
to Haosonn/opencv
that referenced
this pull request
Dec 20, 2023
Ellipses supported added for Einsum Layer opencv#24322 This PR added addresses issues not covered in opencv#24037. Namely these are: Test case for this patch is in this PR [opencv#1106](opencv/opencv_extra#1106) in opencv extra Added: - [x] Broadcasting reduction "...ii ->...I" - [x] Add lazy shape deduction. "...ij, ...jk->...ik" Features to add: - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize - [ ] Performance test ### 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 - [ ] 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
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
Jan 4, 2024
Add Support for Einsum Layer opencv#24037 ### This PR adding support for [Einsum Layer](https://pytorch.org/docs/stable/generated/torch.einsum.html) (in progress). This PR is currently not to be merged but only reviewed. Test cases are located in [opencv#1090](opencv/opencv_extra#1090 in OpenCV extra **DONE**: - [x] 2-5D GMM support added - [x] Matrix transpose support added - [x] Reduction type comupte 'ij->j' - [x] 2nd shape computation - during forward **Next PRs**: - [ ] Broadcasting reduction "...ii ->...i" - [ ] Add lazy shape deduction. "...ij, ...jk->...ik" - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize **Later in 5.x version (requires support for 1D matrices)**: - [ ] Add 1D vector multiplication support - [ ] Inter product "i, i" (problems with 1D shapes) ### 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 - [ ] 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
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
Jan 4, 2024
Ellipses supported added for Einsum Layer opencv#24322 This PR added addresses issues not covered in opencv#24037. Namely these are: Test case for this patch is in this PR [opencv#1106](opencv/opencv_extra#1106) in opencv extra Added: - [x] Broadcasting reduction "...ii ->...I" - [x] Add lazy shape deduction. "...ij, ...jk->...ik" Features to add: - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize - [ ] Performance test ### 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 - [ ] 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
6 tasks
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
May 29, 2024
Add Support for Einsum Layer opencv#24037 ### This PR adding support for [Einsum Layer](https://pytorch.org/docs/stable/generated/torch.einsum.html) (in progress). This PR is currently not to be merged but only reviewed. Test cases are located in [opencv#1090](opencv/opencv_extra#1090 in OpenCV extra **DONE**: - [x] 2-5D GMM support added - [x] Matrix transpose support added - [x] Reduction type comupte 'ij->j' - [x] 2nd shape computation - during forward **Next PRs**: - [ ] Broadcasting reduction "...ii ->...i" - [ ] Add lazy shape deduction. "...ij, ...jk->...ik" - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize **Later in 5.x version (requires support for 1D matrices)**: - [ ] Add 1D vector multiplication support - [ ] Inter product "i, i" (problems with 1D shapes) ### 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 - [ ] 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
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
May 29, 2024
Ellipses supported added for Einsum Layer opencv#24322 This PR added addresses issues not covered in opencv#24037. Namely these are: Test case for this patch is in this PR [opencv#1106](opencv/opencv_extra#1106) in opencv extra Added: - [x] Broadcasting reduction "...ii ->...I" - [x] Add lazy shape deduction. "...ij, ...jk->...ik" Features to add: - [ ] Add implicit output computation support. "bij,bjk ->" (output subscripts should be "bik") - [ ] Add support for CUDA backend - [ ] BatchWiseMultiply optimize - [ ] Performance test ### 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 - [ ] 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adding support for Einsum Layer (in progress).
This PR is currently not to be merged but only reviewed. Test cases are located in #1090RP in OpenCV extra
resolves #23134
resolves #19067
DONE:
Next PRs:
Later in 5.x version (requires support for 1D matrices):
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.