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

[Feature] Ascend backend #747

Merged
merged 54 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f9f3b9c
add acl backend
lzhangzz Jul 12, 2022
49ae2f4
support dynamic batch size and dynamic image size
lzhangzz Jul 13, 2022
c53b55c
add preliminary ascend backend
lzhangzz Jul 14, 2022
ec5762d
support dtypes other than float
lzhangzz Jul 18, 2022
9796e93
support dynamic_dims in SDK
lzhangzz Jul 18, 2022
b5d310b
fix dynamic batch size
lzhangzz Jul 18, 2022
3ec842c
better error handling
lzhangzz Jul 19, 2022
89f6f0d
remove debug info
lzhangzz Jul 19, 2022
c077fc6
[WIP] dynamic shape support
lzhangzz Jul 20, 2022
e7cbdaf
fix static shape
lzhangzz Jul 20, 2022
0233086
fix dynamic batch size
lzhangzz Jul 20, 2022
30955f2
add retinanet support
Jul 20, 2022
5c390d6
fix dynamic image size
lzhangzz Jul 20, 2022
0c596ca
Merge branch 'atlas' of github.com:lzhangzz/mmdeploy into atlas
lzhangzz Jul 20, 2022
4c84ffa
fix dynamic image size
lzhangzz Jul 20, 2022
de3b596
fix dynamic dims
lzhangzz Jul 20, 2022
8420c71
fix dynamic dims
lzhangzz Jul 20, 2022
8a8d0a6
simplify config files
lzhangzz Jul 20, 2022
d2611b5
fix yolox support
Jul 28, 2022
73bda50
fix negative index
Jul 28, 2022
af66d1c
support faster rcnn
Jul 29, 2022
52b1f13
add seg config
Jul 29, 2022
2a8613e
update benchmark
Aug 3, 2022
dd4849d
fix onnx2ascend dynamic shape
Aug 3, 2022
2e437e4
update docstring and benchmark
Aug 5, 2022
b31d506
add unit test, update documents
Aug 8, 2022
4fec92c
merge master
Aug 8, 2022
072dc2e
fix wrapper
Aug 8, 2022
11ef265
fix ut
Aug 8, 2022
87020e4
fix for vit
Aug 12, 2022
e80dc65
error handling
lzhangzz Aug 15, 2022
2a65b54
context handling & multi-device support
lzhangzz Aug 18, 2022
5dff363
build with stub libraries
lzhangzz Aug 29, 2022
f854fbf
add ci
lzhangzz Aug 29, 2022
76d0a65
Merge remote-tracking branch 'zhangli/master' into atlas
lzhangzz Aug 29, 2022
9ff809f
fix lint
lzhangzz Aug 29, 2022
eb84ed0
fix lint
lzhangzz Aug 29, 2022
0f9e773
update doc ref
lzhangzz Aug 29, 2022
cf04247
fix typo
lzhangzz Aug 29, 2022
0434d8a
down with `target_link_directories`
lzhangzz Aug 29, 2022
f05f24f
setup python
lzhangzz Aug 29, 2022
42c56d4
makedir
lzhangzz Aug 29, 2022
a4b284e
fix ci
lzhangzz Aug 29, 2022
0544d8f
fix ci
lzhangzz Aug 29, 2022
26c8ba2
Merge remote-tracking branch 'zhangli/master' into atlas
lzhangzz Aug 29, 2022
28776fe
remove verbose logs
lzhangzz Aug 29, 2022
d2c15fb
fix UBs
lzhangzz Aug 29, 2022
1d2ca0d
export Error
lzhangzz Aug 29, 2022
fd0220d
Merge remote-tracking branch 'zhangli/master' into atlas
lzhangzz Aug 30, 2022
6e7b621
fix lint
lzhangzz Aug 30, 2022
624d119
Merge remote-tracking branch 'zhangli/atlas' into atlas
lzhangzz Aug 30, 2022
5b17c84
update checkenv
Sep 1, 2022
af478f2
Merge remote-tracking branch 'zhangli/master' into atlas
lzhangzz Sep 2, 2022
f7f3c2b
Merge remote-tracking branch 'zhangli/atlas' into atlas
lzhangzz Sep 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .codespell_ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cann
CANN
54 changes: 54 additions & 0 deletions .github/workflows/backend-ascend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: backend-ascend

on:
push:
paths-ignore:
- "demo/**"
- "tools/**"

pull_request:
paths-ignore:
- "demo/**"
- "tools/**"
- "docs/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_sdk_demo:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: update
run: sudo apt update
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev libc++1-9 libc++abi1-9
sudo add-apt-repository ppa:ignaciovizzo/opencv3-nonfree
sudo apt install libopencv-dev
pkg-config --libs opencv
- name: Install Ascend Toolkit
run: |
mkdir -p $GITHUB_WORKSPACE/Ascend
wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%205.1.RC2/Ascend-cann-toolkit_5.1.RC2_linux-x86_64.run
sh Ascend-cann-toolkit_5.1.RC2_linux-x86_64.run --install --install-path=$GITHUB_WORKSPACE/Ascend --quiet --chip=Ascend310 --blacklist=devtools
- name: Build SDK Demo with Ascend backend
run: |
mkdir -p build && pushd build
source $GITHUB_WORKSPACE/Ascend/ascend-toolkit/set_env.sh
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/Ascend/ascend-toolkit/latest/runtime/lib64/stub:$LD_LIBRARY_PATH
cmake .. -DCMAKE_CXX_COMPILER=g++-7 -DMMDEPLOY_SHARED_LIBS=ON -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=OFF -DMMDEPLOY_TARGET_DEVICES=cpu -DMMDEPLOY_BUILD_EXAMPLES=ON -DMMDEPLOY_TARGET_BACKENDS=acl -DMMDEPLOY_CODEBASES=all
make install -j4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ mmdeploy/backend/ncnn/onnx2ncnn

/mmdeploy-*

# ascend
fusion_result.json

# snpe
grpc-cpp-plugin
service/snpe/grpc_cpp_plugin
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ The currently supported codebases and models are as follows, and more will be in

Models can be exported and run in the following backends, and more will be compatible

| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ---------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/en/03-benchmark/benchmark.md) |
| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | Ascend | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ------ | ---------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/en/03-benchmark/benchmark.md) |

### Efficient and scalable C/C++ SDK Framework

Expand Down
6 changes: 3 additions & 3 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为

### 支持多种推理后端

| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ------------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/zh_cn/03-benchmark/benchmark.md) |
| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | Ascend | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ------ | ------------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/zh_cn/03-benchmark/benchmark.md) |

### SDK 可高度定制化

Expand Down
1 change: 1 addition & 0 deletions configs/_base_/backends/ascend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
backend_config = dict(type='ascend')
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_base_ = ['./classification_dynamic.py', '../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[224, 224])

backend_config = dict(model_inputs=[
dict(
dynamic_batch_size=[1, 2, 4, 8],
lvhan028 marked this conversation as resolved.
Show resolved Hide resolved
input_shapes=dict(input=[-1, 3, 224, 224]))
])
5 changes: 5 additions & 0 deletions configs/mmcls/classification_ascend_static-224x224.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['./classification_static.py', '../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[224, 224])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 224, 224]))])
8 changes: 8 additions & 0 deletions configs/mmdet/detection/detection_ascend_dynamic-800x1344.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_base_ = ['../_base_/base_dynamic.py', '../../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[1344, 800])
backend_config = dict(model_inputs=[
dict(
dynamic_image_size=[(800, 1344), (1344, 800)],
input_shapes=dict(input=[1, 3, -1, -1]))
])
5 changes: 5 additions & 0 deletions configs/mmdet/detection/detection_ascend_static-640x640.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['../_base_/base_static.py', '../../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[640, 640])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 640, 640]))])
5 changes: 5 additions & 0 deletions configs/mmdet/detection/detection_ascend_static-800x1344.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['../_base_/base_static.py', '../../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[1344, 800])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 800, 1344]))])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_base_ = ['./text-detection_dynamic.py', '../../_base_/backends/ascend.py']

onnx_config = dict(input_shape=None)
backend_config = dict(model_inputs=[
dict(
input_shapes=dict(input=[-1, 3, -1, -1]),
dynamic_dims=[(1, 640, 640), (4, 640, 640), (1, 1280, 1280)])
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['./text-detection_static.py', '../../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[640, 640])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 640, 640]))])
5 changes: 5 additions & 0 deletions configs/mmseg/segmentation_ascend_static-1024x2048.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['./segmentation_static.py', '../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[2048, 1024])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 1024, 2048]))])
5 changes: 5 additions & 0 deletions configs/mmseg/segmentation_ascend_static-512x1024.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['./segmentation_static.py', '../_base_/backends/ascend.py']

onnx_config = dict(input_shape=[1024, 512])
backend_config = dict(
model_inputs=[dict(input_shapes=dict(input=[1, 3, 512, 1024]))])
1 change: 1 addition & 0 deletions csrc/mmdeploy/codebase/mmdet/object_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "mmdeploy/core/registry.h"
#include "mmdeploy/core/utils/device_utils.h"
#include "mmdeploy/core/utils/formatter.h"
#include "mmdeploy/experimental/module_adapter.h"

using namespace std;
Expand Down
Loading