New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dnn: expand refactor with cv::broadcast for onnx models #24295
Conversation
89929d6
to
4e72c5a
Compare
4e72c5a
to
cf0ea25
Compare
@fengyuentau Could the patch unlock some "conformance" tests for ONNX? |
@asmorkalov Unfortunately, all Expand conformance tests have input |
…ues; add early copy for unchanged total elements
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
|
CI is not passing again because of #24300 |
All tests are green now. |
* 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
* 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
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::broadcast
already, 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.