diff --git a/README.md b/README.md index 7ddd543a11b0ae774c4da44a51d4e890f409df45..2fdd1cc9760f1785ca781b585dd797a31820e0c1 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ OneFlow 相关的模型转换工具 #### 简介 -- OneFlow2ONNX 模型支持,支持 OneFlow 动态图模型转为 ONNX,详情可以参考 [OneFlow2ONNX 模型列表](docs/oneflow2onnx/oneflow2onnx_model_zoo.md)。 -- OneFlow2ONNX 算子支持,支持 CV 中大部分常见算子,详情可以参考 [OneFlow2ONNX 算子列表](docs/oneflow2onnx/op_list.md)。 +- OneFlow2ONNX 模型支持,支持 OneFlow 静态图模型转为 ONNX,可转换由 [flow.checkpoint.save ](https://docs.oneflow.org/basics_topics/model_load_save.html) 方法保存下来的 OneFlow 模型,详情可以参考 [OneFlow2ONNX 模型列表](docs/oneflow2onnx/oneflow2onnx_model_zoo.md)。 +- OneFlow2ONNX 算子支持,目前稳定支持导出 ONNX Opset10,部分 OneFlow 算子支持更低的 ONNX Opset 转换,详情可以参考 [OneFlow2ONNX 算子列表](docs/oneflow2onnx/op_list.md)。 #### 环境依赖 @@ -25,6 +25,8 @@ OneFlow 相关的模型转换工具 ```sh python>=3.5 onnx>=1.8.0 +onnx-simplifier>=0.3.3 +onnxoptimizer>=0.2.5 onnxruntime>=1.6.0 oneflow>=0.5.0 ``` diff --git a/README_en.md b/README_en.md index e2a799216f23789f133ca9d41f71090ebd93b78a..00afe9844ec6fdf8cbb2d8e905453fcc23da05d2 100644 --- a/README_en.md +++ b/README_en.md @@ -10,8 +10,8 @@ #### Introduction -- OneFlow2ONNX models are supported. Specifically, OneFlow's eager mode model can be transfomed into ONNX's format. For more information, please refer to [OneFlow2ONNX Model List](docs/oneflow2onnx/oneflow2onnx_model_zoo.md). -- OneFlow2ONNX operators are supported. Please refer to [OneFlow2ONNX Operator Lists](docs/oneflow2onnx/op_list.md) for more information. +- OneFlow2ONNX models are supported. Specifically, OneFlow's lazy mode model can be transfomed into ONNX's format. Transformable OneFlow model can be obtained by using the method explained on [flow.checkpoint.save ](https://docs.oneflow.org/basics_topics/model_load_save.html). For more information, please refer to [OneFlow2ONNX Model List](docs/oneflow2onnx/oneflow2onnx_model_zoo.md). +- OneFlow2ONNX operators are supported. Currently, oneflow_onnx is fully capable of exporting ONNX Opset10, and parts of OneFlow operator can transform ONNX Opsets that are in lower order. Please refer to [OneFlow2ONNX Operator Lists](docs/oneflow2onnx/op_list.md) for more information. #### Environment Dependencies @@ -21,6 +21,8 @@ ```sh python>=3.5 onnx>=1.8.0 +onnx-simplifier>=0.3.3 +onnxoptimizer>=0.2.5 onnxruntime>=1.6.0 oneflow (https://github.com/Oneflow-Inc/oneflow#install-with-pip-package) ``` diff --git a/examples/oneflow2onnx/models/test_alexnet.py b/examples/oneflow2onnx/models/test_alexnet.py index 20b6eaaa9713e5addf572773b7f64f05d60bf9d0..4d557077f9cf52e497f7e368cc8534da2cca6059 100644 --- a/examples/oneflow2onnx/models/test_alexnet.py +++ b/examples/oneflow2onnx/models/test_alexnet.py @@ -74,6 +74,6 @@ def test_alexnet(): with tempfile.TemporaryDirectory() as tmpdirname: flow.save(alexnet.state_dict(), tmpdirname) - convert_to_onnx_and_check(alexnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(alexnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_alexnet() diff --git a/examples/oneflow2onnx/models/test_inceptionv3.py b/examples/oneflow2onnx/models/test_inceptionv3.py index d6f697defd4157e8b7fc8b10f4fe82cb4de6c820..86db1afd4743d552d865c971883c039b5c52593b 100644 --- a/examples/oneflow2onnx/models/test_inceptionv3.py +++ b/examples/oneflow2onnx/models/test_inceptionv3.py @@ -468,8 +468,8 @@ def test_inceptionv3(): inceptionv3_graph = inceptionv3Graph() inceptionv3_graph._compile(flow.randn(1, 3, 299, 299).to("cuda")) - # with tempfile.TemporaryDirectory() as tmpdirname: - # flow.save(inceptionv3.state_dict(), tmpdirname) - # convert_to_onnx_and_check(inceptionv3_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + with tempfile.TemporaryDirectory() as tmpdirname: + flow.save(inceptionv3.state_dict(), tmpdirname) + convert_to_onnx_and_check(inceptionv3_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_inceptionv3() diff --git a/examples/oneflow2onnx/models/test_lenet.py b/examples/oneflow2onnx/models/test_lenet.py index b56bb88eec20ef89ab1780aa1dbac90eb6b54f3f..b9a7a58d18a21ab89bcc8c16f9242fbf9ae3f208 100644 --- a/examples/oneflow2onnx/models/test_lenet.py +++ b/examples/oneflow2onnx/models/test_lenet.py @@ -62,6 +62,6 @@ def test_lenet(): with tempfile.TemporaryDirectory() as tmpdirname: flow.save(lenet.state_dict(), tmpdirname) - convert_to_onnx_and_check(lenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(lenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_lenet() diff --git a/examples/oneflow2onnx/models/test_mobilenet_v2.py b/examples/oneflow2onnx/models/test_mobilenet_v2.py index 815b94cce6f7e775117480344cbfb95489832f58..b21def65f71f63d979558eea7245520e917b415e 100644 --- a/examples/oneflow2onnx/models/test_mobilenet_v2.py +++ b/examples/oneflow2onnx/models/test_mobilenet_v2.py @@ -272,6 +272,6 @@ def test_mobilenetv2(): # print(mobilenetv2_graph._full_graph_proto) with tempfile.TemporaryDirectory() as tmpdirname: flow.save(mobilenetv2.state_dict(), tmpdirname) - convert_to_onnx_and_check(mobilenetv2_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(mobilenetv2_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_mobilenetv2() diff --git a/examples/oneflow2onnx/models/test_repvgg.py b/examples/oneflow2onnx/models/test_repvgg.py index 24caf5010af7ddae7d165001a2de5b521b37bc3c..54a83dce342e8d640b726876ee09805e0a7956dd 100644 --- a/examples/oneflow2onnx/models/test_repvgg.py +++ b/examples/oneflow2onnx/models/test_repvgg.py @@ -391,6 +391,6 @@ def test_repvgg(): with tempfile.TemporaryDirectory() as tmpdirname: flow.save(repvgg.state_dict(), tmpdirname) - convert_to_onnx_and_check(repvgg_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(repvgg_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_repvgg() diff --git a/examples/oneflow2onnx/models/test_resnet50.py b/examples/oneflow2onnx/models/test_resnet50.py index 35abb8d499bd3fbaf908df8c889ce7fdbb020fdc..9e274d9c04e3c7748987dc7c105778517ee2af15 100644 --- a/examples/oneflow2onnx/models/test_resnet50.py +++ b/examples/oneflow2onnx/models/test_resnet50.py @@ -312,6 +312,6 @@ def test_resnet(): print(resnet_graph._full_graph_proto) with tempfile.TemporaryDirectory() as tmpdirname: flow.save(resnet.state_dict(), tmpdirname) - convert_to_onnx_and_check(resnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(resnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=False) test_resnet() diff --git a/examples/oneflow2onnx/models/test_shufflenetv2.py b/examples/oneflow2onnx/models/test_shufflenetv2.py index 7efdf961729f787442a3c2c417ce256ddabe721d..cf8c4f959c674664af4615a9ca441399fd6631de 100644 --- a/examples/oneflow2onnx/models/test_shufflenetv2.py +++ b/examples/oneflow2onnx/models/test_shufflenetv2.py @@ -215,6 +215,6 @@ def test_shufflenet(): with tempfile.TemporaryDirectory() as tmpdirname: flow.save(shufflenet.state_dict(), tmpdirname) - convert_to_onnx_and_check(shufflenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(shufflenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_shufflenet() diff --git a/examples/oneflow2onnx/models/test_vgg.py b/examples/oneflow2onnx/models/test_vgg.py index 63165fd6ae97afad453b05d9ba11b9258c33ae27..f3ef5c07c6c5771ff97222af71d3b3f0e56a2ffb 100644 --- a/examples/oneflow2onnx/models/test_vgg.py +++ b/examples/oneflow2onnx/models/test_vgg.py @@ -190,6 +190,6 @@ def test_vgg16(): with tempfile.TemporaryDirectory() as tmpdirname: flow.save(vgg16.state_dict(), tmpdirname) - convert_to_onnx_and_check(vgg16_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True) + convert_to_onnx_and_check(vgg16_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp") test_vgg16() diff --git a/requirements.txt b/requirements.txt index 5d756443f79aab180352a9969e653f486014a085..20a2f1dcb4d83dfa98ed6d7dd76c0902f4c3c74d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ onnx>=1.8.0 +onnx-simplifier>=0.3.3 +onnxoptimizer>=0.2.5 onnxruntime-gpu>=1.8.0 diff --git a/setup.py b/setup.py index 9d624bc3e0ab42484c145cf347924ebdb871f10b..7c4c00be40a0516616291d2c89d710fc526d61ce 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,11 @@ long_description += "Email: zhangxiaoyu@oneflow.org" setuptools.setup( name="oneflow_onnx", +<<<<<<< HEAD version="0.5.1", +======= + version="0.5.0.rc", +>>>>>>> parent of cca89ba... release v0.5.0 (#42) author="zhangxiaoyu", author_email="zhangxiaoyu@oneflow.org", description="a toolkit for converting trained model of OneFlow to ONNX and ONNX to OneFlow.",