dnn: expand refactor with cv::broadcast for onnx models#24295
Merged
vpisarev merged 10 commits intoopencv:4.xfrom Sep 27, 2023
Merged
dnn: expand refactor with cv::broadcast for onnx models#24295vpisarev merged 10 commits intoopencv:4.xfrom
vpisarev merged 10 commits intoopencv:4.xfrom
Conversation
89929d6 to
4e72c5a
Compare
4e72c5a to
cf0ea25
Compare
Contributor
|
@fengyuentau Could the patch unlock some "conformance" tests for ONNX? |
Member
Author
|
@asmorkalov Unfortunately, all Expand conformance tests have input |
4 tasks
…ues; add early copy for unchanged total elements
Member
Author
|
CI will not pass due to #24308. Decided to fix the issue here in this pull request. Basically the wrong result is given because of opencv/modules/dnn/src/onnx/onnx_graph_simplifier.cpp Lines 824 to 840 in 3889dcf |
Member
Author
|
CI is not passing again because of #24300 |
Member
Author
|
All tests are green now. |
vpisarev
approved these changes
Sep 27, 2023
8 tasks
Merged
hanliutong
pushed a commit
to hanliutong/opencv
that referenced
this pull request
Oct 7, 2023
* add expand impl with cv::broadcast * remove expandMid * deduce shape from -1 * add constant folding * handle input constant; handle input constant 1d * add expand conformance tests; add checks to disallow shape of neg values; add early copy for unchanged total elements * fix ExpandSubgraph * dummy commit to trigger build * dummy commit to trigger build 1 * remove conformance from test names
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
Jan 4, 2024
* add expand impl with cv::broadcast * remove expandMid * deduce shape from -1 * add constant folding * handle input constant; handle input constant 1d * add expand conformance tests; add checks to disallow shape of neg values; add early copy for unchanged total elements * fix ExpandSubgraph * dummy commit to trigger build * dummy commit to trigger build 1 * remove conformance from test names
48 tasks
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
May 29, 2024
* add expand impl with cv::broadcast * remove expandMid * deduce shape from -1 * add constant folding * handle input constant; handle input constant 1d * add expand conformance tests; add checks to disallow shape of neg values; add early copy for unchanged total elements * fix ExpandSubgraph * dummy commit to trigger build * dummy commit to trigger build 1 * remove conformance from test names
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.
Resolves #24300
Resolves #24308
Merge with opencv/opencv_extra#1098.
Motivation:
Current implementation of ONNX Expand is very limited and hard to maintain. It can go very unefficient, e.g. input of shape [1, 5, 1] and shape of value [1, 5, 256], it leads to 256 x [1, 5, 1] constant nodes along with a concat node. See down below for more details .
opencv/modules/dnn/src/onnx/onnx_importer.cpp
Lines 2485 to 2494 in b870ad4
Since now we have
cv::broadcastalready, it is time to do a refactor on expand.Checklist:
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.