Skip to content
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 CANN backend: fix some bugs and add some features #23319

Merged
merged 7 commits into from Mar 13, 2023

Conversation

fengyuentau
Copy link
Member

@fengyuentau fengyuentau commented Mar 2, 2023

Related issue: opencv/opencv_zoo#136

Features added:

  • Support operators with multiple output: ONNX Split.
  • Support Slice without steps.

Bugs fixed:

  • Wrong settings in ClipByValue (Relu6).
  • Wrong calculation of pads in convolution layer (It is wrong generally but only fixed specifically for CANN for now).

Pull Request Readiness Checklist

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

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • 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.
  • The feature is well documented and sample code can be built with the project CMake

@fengyuentau fengyuentau marked this pull request as ready for review March 8, 2023 05:55
@fengyuentau fengyuentau changed the title dnn CANN backend: support nodes with multiple outputs dnn CANN backend: fix some bugs and add some features Mar 8, 2023
@fengyuentau fengyuentau added this to the 4.8.0 milestone Mar 9, 2023
Comment on lines +809 to +823
if (padMode == "SAME")
{
for (int i = 0; i < pads_begin.size(); i++) {
if (strides[i] <= kernel_size[i])
{
int pads_at_i = kernel_size[i] - 1 - (shape_x[i+2] - 1 + strides[i]) % strides[i];
pads_begin[i] = pads_at_i / 2;
// if odd, add extra padding to the end for SAME_UPPER
// or to the beginning for SAME_LOWER. Since here we cannot
// identity SAME_UPPER and SAME_LOWER, extra padding is always
// added to the end.
pads_end[i] = pads_at_i - pads_begin[i];
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporal solution of "SAME pad mode to pads" calculation specifically for CANN. Will submit another pull request to fix for all backends if possible.

@asmorkalov asmorkalov merged commit b94e13c into opencv:4.x Mar 13, 2023
18 checks passed
hanliutong pushed a commit to hanliutong/opencv that referenced this pull request Mar 27, 2023
Related issue: opencv/opencv_zoo#136

Features added:

- Support operators with multiple output: ONNX Split.
- Support Slice without steps.

Bugs fixed:

- Wrong settings in ClipByValue (Relu6).
- Wrong calculation of pads in convolution layer (It is wrong generally but only fixed specifically for CANN for now).

### 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
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
@fengyuentau fengyuentau deleted the fix_zoo_issue_136 branch June 24, 2023 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category:dnn_cann CANN backend related issues in DNN module category: dnn
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants