From a67950d8587aa01645a9e8069110bba9351afbae Mon Sep 17 00:00:00 2001 From: wjj19950828 Date: Tue, 6 Sep 2022 10:56:17 +0800 Subject: [PATCH] set enable_code_optim default to false --- README.md | 2 +- docs/inference_model_convertor/pytorch2paddle.md | 2 +- docs/inference_model_convertor/x2paddle_api.md | 4 ++-- x2paddle/convert.py | 4 ++-- x2paddle/core/program.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b0f6dfe..df59728 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ x2paddle --framework=caffe --prototxt=deploy.prototxt --weight=deploy.caffemodel | --model | 当framework为tensorflow/onnx时,该参数指定tensorflow的pb模型文件或onnx模型路径 | | --caffe_proto | **[可选]** 由caffe.proto编译成caffe_pb2.py文件的存放路径,当存在自定义Layer时使用,默认为None | | --define_input_shape | **[可选]** For TensorFlow, 当指定该参数时,强制用户输入每个Placeholder的shape,见[文档Q2](./docs/inference_model_convertor/FAQ.md) | -| --enable_code_optim | **[可选]** For PyTorch, 是否对生成代码进行优化,默认为True | +| --enable_code_optim | **[可选]** For PyTorch, 是否对生成代码进行优化,默认为False | | --to_lite | **[可选]** 是否使用opt工具转成Paddle-Lite支持格式,默认为False | | --lite_valid_places | **[可选]** 指定转换类型,可以同时指定多个backend(以逗号分隔),opt将会自动选择最佳方式,默认为arm | | --lite_model_type | **[可选]** 指定模型转化类型,目前支持两种类型:protobuf和naive_buffer,默认为naive_buffer | diff --git a/docs/inference_model_convertor/pytorch2paddle.md b/docs/inference_model_convertor/pytorch2paddle.md index 2fc49d3..d1f0248 100644 --- a/docs/inference_model_convertor/pytorch2paddle.md +++ b/docs/inference_model_convertor/pytorch2paddle.md @@ -40,7 +40,7 @@ pytorch2paddle(module=torch_module, import torch import numpy as np from torchvision.models import AlexNet -from torchvision.models.utils import load_state_dict_from_url +from torch.hub import load_state_dict_from_url # 构建输入 input_data = np.random.rand(1, 3, 224, 224).astype("float32") # 获取PyTorch Module diff --git a/docs/inference_model_convertor/x2paddle_api.md b/docs/inference_model_convertor/x2paddle_api.md index c6ee37d..ff56f4a 100644 --- a/docs/inference_model_convertor/x2paddle_api.md +++ b/docs/inference_model_convertor/x2paddle_api.md @@ -63,7 +63,7 @@ x2paddle.convert.onnx2paddle(model_path, save_dir, convert_to_lite=False, lite_v ##

x2paddle.convert.pytorch2paddle

```python -x2paddle.convert.pytorch2paddle(module, save_dir, jit_type="trace", input_examples=None, enable_code_optim=True, convert_to_lite=False, lite_valid_places="arm", lite_model_type="naive_buffer") +x2paddle.convert.pytorch2paddle(module, save_dir, jit_type="trace", input_examples=None, enable_code_optim=False, convert_to_lite=False, lite_valid_places="arm", lite_model_type="naive_buffer") ``` > 转换Pytorch模型。 @@ -74,7 +74,7 @@ x2paddle.convert.pytorch2paddle(module, save_dir, jit_type="trace", input_exampl > > - **save_dir** (str): 转换后模型保存路径 > > - **jit_type** (str): 转换方式。目前有两种:trace和script, 默认为trace > > - **input_examples** (list[torch.tensor]): torch.nn. Module的输入示例,list的长度必须与输入的长度一致。默认为None -> > - **enable_code_optim** (bool): 转换后的代码是否进行优化, 默认为True +> > - **enable_code_optim** (bool): 转换后的代码是否进行优化, 默认为False > > - **convert_to_lite** (bool): 是否使用opt工具转成Paddle-Lite支持格式,默认为False > > - **lite_valid_places** (str): 指定转换类型,可以同时指定多个backend(以逗号分隔),opt将会自动选择最佳方式,默认为arm > > - **lite_model_type** (str): 指定模型转化类型,目前支持两种类型:protobuf和naive_buffer,默认为naive_buffer diff --git a/x2paddle/convert.py b/x2paddle/convert.py index a14a0af..336feb3 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -93,7 +93,7 @@ def arg_parser(): parser.add_argument( "--enable_code_optim", "-co", - default=True, + default=False, help="Turn on code optimization") parser.add_argument( "--enable_onnx_checker", @@ -329,7 +329,7 @@ def pytorch2paddle(module, save_dir, jit_type="trace", input_examples=None, - enable_code_optim=True, + enable_code_optim=False, convert_to_lite=False, lite_valid_places="arm", lite_model_type="naive_buffer", diff --git a/x2paddle/core/program.py b/x2paddle/core/program.py index 7d1ba96..7b88864 100755 --- a/x2paddle/core/program.py +++ b/x2paddle/core/program.py @@ -260,7 +260,7 @@ class PaddleGraph(object): return update(self.layers) - def gen_model(self, save_dir, jit_type=None, enable_code_optim=True): + def gen_model(self, save_dir, jit_type=None, enable_code_optim=False): if not osp.exists(save_dir): os.makedirs(save_dir) if jit_type == "trace": -- GitLab