Unverified Commit 477f0c0a authored by RunningLeon's avatar RunningLeon Committed by GitHub
Browse files

[Fix]: Set installation of onnx simplify's related packages to optional (#779)

* Fix onnx, onnxruntime, onnxoptimizer import

* Revert "Fix onnx, onnxruntime, onnxoptimizer import"

This reverts commit 820e3785a1144eb85e1ba22688dada681ea4c829.

* remove simplify from init file

* update test for onnx simplify

* update onnx doc
parent 51a0c23f
......@@ -20,6 +20,14 @@ register_extra_symbolics(opset_version)
`mmcv.onnx.simplify` is based on [onnx-simplifier](https://github.com/daquexian/onnx-simplifier), which is a useful tool to make exported ONNX models slimmer by performing a series of optimization. However, for Pytorch models with custom op from `mmcv`, it would break down. Thus, custom ops for ONNX Runtime should be registered.
### Prerequisite
`mmcv.onnx.simplify` has three dependencies: `onnx`, `onnxoptimizer`, `onnxruntime`. After installation of `mmcv`, you have to install them manually using pip.
```bash
pip install onnx onnxoptimizer onnxruntime
```
### Usage
```python
......@@ -27,7 +35,8 @@ import onnx
import numpy as np
import mmcv
from mmcv.onnx import simplify
from mmcv.onnx.simplify import simplify
dummy_input = np.random.randn(1, 3, 224, 224).astype(np.float32)
input = {'input':dummy_input}
input_file = 'sample.onnx'
......
from .info import is_custom_op_loaded
from .simplify import simplify
from .symbolic import register_extra_symbolics
__all__ = ['register_extra_symbolics', 'simplify', 'is_custom_op_loaded']
__all__ = ['register_extra_symbolics', 'is_custom_op_loaded']
......@@ -271,7 +271,7 @@ def test_roipool():
def test_simplify():
from mmcv.onnx import simplify
from mmcv.onnx.simplify import simplify
# only support PyTorch >= 1.5.0
if version.parse(torch.__version__) < version.parse('1.5.0'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment