Skip to content

dnn CANN backend: fix some bugs and add some features#23319

Merged
asmorkalov merged 7 commits intoopencv:4.xfrom
fengyuentau:fix_zoo_issue_136
Mar 13, 2023
Merged

dnn CANN backend: fix some bugs and add some features#23319
asmorkalov merged 7 commits intoopencv:4.xfrom
fengyuentau:fix_zoo_issue_136

Conversation

@fengyuentau
Copy link
Copy Markdown
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
Copy Markdown
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
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.

3 participants