[Docs] adding new backends when using MMDeploy as a third package (#482)

* update doc

* refine expression

* cn doc
pull/538/head
AllentDan 2022-05-27 14:23:28 +08:00 committed by GitHub
parent 32482e76fd
commit 571b240500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -229,3 +229,20 @@ Although the backend engines are usually implemented in C/C++, it is convenient
```
5. Add docstring and unit tests for new code :).
### Support new backends using MMDeploy as a third party
Previous parts show how to add a new backend in MMDeploy, which requires changing its source codes. However, if we treat MMDeploy as a third party, the methods above are no longer efficient. To this end, adding a new backend requires us pre-install another package named `aenum`. We can install it directly through `pip install aenum`.
After installing `aenum` successfully, we can use it to add a new backend through:
```python
from mmdeploy.utils.constants import Backend
from aenum import extend_enum
try:
Backend.get('backend_name')
except Exception:
extend_enum(Backend, 'BACKEND', 'backend_name')
```
We can run the codes above before we use the rewrite logic of MMDeploy.

View File

@ -229,3 +229,19 @@ MMDeploy 中的后端必须支持 ONNX因此后端能直接加载“.onnx”
```
5. 为新后端引擎代码添加相关注释和单元测试 :).
### 将MMDeploy作为第三方库时添加新后端
前面的部分展示了如何在 MMDeploy 中添加新的后端,这需要更改其源代码。但是,如果我们将 MMDeploy 视为第三方,则上述方法不再有效。为此,添加一个新的后端需要我们预先安装另一个名为 `aenum` 的包。我们可以直接通过`pip install aenum`进行安装。
成功安装 `aenum` 后,我们可以通过以下方式使用它来添加新的后端:
```python
from mmdeploy.utils.constants import Backend
from aenum import extend_enum
try:
Backend.get('backend_name')
except Exception:
extend_enum(Backend, 'BACKEND', 'backend_name')
```
我们可以在使用 MMDeploy 的重写逻辑之前运行上面的代码,这就完成了新后端的添加。