8000 dnn cann backend: add hardswish, layernorm and instasnce norm for cann and bug fix by fengyuentau · Pull Request #24462 · opencv/opencv · GitHub
[go: up one dir, main page]

Skip to content

dnn cann backend: add hardswish, layernorm and instasnce norm for cann and bug fix #24462

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

Merged
merged 10 commits into from
Nov 15, 2023

Conversation

fengyuentau
Copy link
Member
@fengyuentau fengyuentau commented Oct 27, 2023

Resolves #24154
Resolves opencv/ci-gha-workflow#120 (comment)

New CANN operator added in this PR:

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 added the category:dnn_cann CANN backend related issues in DNN module label Oct 27, 2023
@fengyuentau fengyuentau added this to the 4.9.0 milestone Oct 27, 2023
@asmorkalov asmorkalov requested a review from vpisarev October 27, 2023 11:28
@fengyuentau
Copy link
Member Author

Will finalize this PR after the merge of #24409.

@fengyuentau fengyuentau mentioned this pull request Nov 3, 2023
12 tasks
asmorkalov pushed a commit that referenced this pull request Nov 7, 2023
dnn onnx: add instance norm layer #24378

Resolves #24377
Relates #24092 (comment)

| Perf | multi-thread | single-thread |
| - | - | - |
| x: [2, 64, 180, 240] | 3.95ms | 11.12ms |

Todo:

- [x] speed up by multi-threading
- [x] add perf
- [x] add backend: OpenVINO
- [x] add backend: CUDA
- [x] add backend: OpenCL (no fp16)
- [ ] add backend: CANN (will be done via #24462)


### 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

```
force_builders=Linux OpenCL,Win64 OpenCL,Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu:18.04
modules_filter:Custom=none
disable_ipp:Custom=ON
```
@fengyuentau fengyuentau force-pushed the cann_support_hardswish branch from 01a16b5 to 07559e8 Compare November 10, 2023 09:50
@fengyuentau
Copy link
Member Author

Will test this PR next week.

@fengyuentau fengyuentau marked this pull request as ready for review November 10, 2023 11:02
@fengyuentau
Copy link
Member Author
fengyuentau commented Nov 13, 2023

Tests on Hardswish and LayerNormalization are passed with threshold 1e-3. However, due to the 1D mat shape problem, LayerNormalization with axis=-1 on CANN backend produces incorrect results, and InstanceNormalization on CANN backend leads to incorrect shape inference when building graph. So they are turned off for CANN backend for now.

I think this PR can be merged and we leave the 1d mat shape problem to the future.

@fengyuentau fengyuentau changed the title dnn cann backend: add hardswish for cann and bug fix dnn cann backend: add hardswish, layernorm and instasnce norm for cann and bug fix Nov 15, 2023
@vpisarev vpisarev merged commit 024dfd5 into opencv:4.x Nov 15, 2023
@fengyuentau fengyuentau deleted the cann_support_hardswish branch November 15, 2023 15:07
@jimmylaw21 jimmylaw21 mentioned this pull request Dec 17, 2023
12 tasks
IskXCr pushed a commit to Haosonn/opencv that referenced this pull request Dec 20, 2023
dnn onnx: add instance norm layer opencv#24378

Resolves opencv#24377
Relates opencv#24092 (comment)

| Perf | multi-thread | single-thread |
| - | - | - |
| x: [2, 64, 180, 240] | 3.95ms | 11.12ms |

Todo:

- [x] speed up by multi-threading
- [x] add perf
- [x] add backend: OpenVINO
- [x] add backend: CUDA
- [x] add backend: OpenCL (no fp16)
- [ ] add backend: CANN (will be done via opencv#24462)


### 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

```
force_builders=Linux OpenCL,Win64 OpenCL,Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu:18.04
modules_filter:Custom=none
disable_ipp:Custom=ON
```
IskXCr pushed a commit to Haosonn/opencv that referenced this pull request Dec 20, 2023
…n and bug fix (opencv#24462)

* add hardswish for cann

* gemm cann bug fix

* fix indentation

* cann: add layer norm

* cann: add instance norm

* add supportBackend

* cann: layer norm does not support axis=-1 due to 1d mat issue

* disable instance norm for now

* fix doc

* remove tensor desc initialization for 1D tensor
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
dnn onnx: add instance norm layer opencv#24378

Resolves opencv#24377
Relates opencv#24092 (comment)

| Perf | multi-thread | single-thread |
| - | - | - |
| x: [2, 64, 180, 240] | 3.95ms | 11.12ms |

Todo:

- [x] speed up by multi-threading
- [x] add perf
- [x] add backend: OpenVINO
- [x] add backend: CUDA
- [x] add backend: OpenCL (no fp16)
- [ ] add backend: CANN (will be done via opencv#24462)


### 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

```
force_builders=Linux OpenCL,Win64 OpenCL,Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu:18.04
modules_filter:Custom=none
disable_ipp:Custom=ON
```
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
…n and bug fix (opencv#24462)

* add hardswish for cann

* gemm cann bug fix

* fix indentation

* cann: add layer norm

* cann: add instance norm

* add supportBackend

* cann: layer norm does not support axis=-1 due to 1d mat issue

* disable instance norm for now

* fix doc

* remove tensor desc initialization for 1D tensor
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
dnn onnx: add instance norm layer opencv#24378

Resolves opencv#24377
Relates opencv#24092 (comment)

| Perf | multi-thread | single-thread |
| - | - | - |
| x: [2, 64, 180, 240] | 3.95ms | 11.12ms |

Todo:

- [x] speed up by multi-threading
- [x] add perf
- [x] add backend: OpenVINO
- [x] add backend: CUDA
- [x] add backend: OpenCL (no fp16)
- [ ] add backend: CANN (will be done via opencv#24462)


### 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

```
force_builders=Linux OpenCL,Win64 OpenCL,Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu:18.04
modules_filter:Custom=none
disable_ipp:Custom=ON
```
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
…n and bug fix (opencv#24462)

* add hardswish for cann

* gemm cann bug fix

* fix indentation

* cann: add layer norm

* cann: add instance norm

* add supportBackend

* cann: layer norm does not support axis=-1 due to 1d mat issue

* disable instance norm for now

* fix doc

* remove tensor desc initialization for 1D tensor
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 feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HardSwish is not supported by CANN backend
2 participants
0