Skip to content

Commit 75a25c0

Browse files
authored
Merge pull request #889 from wjj19950828/Add_onnx_tests
Set enable_code_optim default to False
2 parents 963ac9b + 5ad3880 commit 75a25c0

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ x2paddle --framework=caffe --prototxt=deploy.prototxt --weight=deploy.caffemodel
117117
| --model | 当framework为tensorflow/onnx时,该参数指定tensorflow的pb模型文件或onnx模型路径 |
118118
| --caffe_proto | **[可选]** 由caffe.proto编译成caffe_pb2.py文件的存放路径,当存在自定义Layer时使用,默认为None |
119119
| --define_input_shape | **[可选]** For TensorFlow, 当指定该参数时,强制用户输入每个Placeholder的shape,见[文档Q2](./docs/inference_model_convertor/FAQ.md) |
120-
| --enable_code_optim | **[可选]** For PyTorch, 是否对生成代码进行优化,默认为True |
120+
| --enable_code_optim | **[可选]** For PyTorch, 是否对生成代码进行优化,默认为False |
121121
| --to_lite | **[可选]** 是否使用opt工具转成Paddle-Lite支持格式,默认为False |
122122
| --lite_valid_places | **[可选]** 指定转换类型,可以同时指定多个backend(以逗号分隔),opt将会自动选择最佳方式,默认为arm |
123123
| --lite_model_type | **[可选]** 指定模型转化类型,目前支持两种类型:protobuf和naive_buffer,默认为naive_buffer |

docs/inference_model_convertor/pytorch2paddle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pytorch2paddle(module=torch_module,
4040
import torch
4141
import numpy as np
4242
from torchvision.models import AlexNet
43-
from torchvision.models.utils import load_state_dict_from_url
43+
from torch.hub import load_state_dict_from_url
4444
# 构建输入
4545
input_data = np.random.rand(1, 3, 224, 224).astype("float32")
4646
# 获取PyTorch Module

docs/inference_model_convertor/x2paddle_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ x2paddle.convert.onnx2paddle(model_path, save_dir, convert_to_lite=False, lite_v
6363
## <h2 id="4">x2paddle.convert.pytorch2paddle</h2>
6464

6565
```python
66-
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")
66+
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")
6767
```
6868

6969
> 转换Pytorch模型。
@@ -74,7 +74,7 @@ x2paddle.convert.pytorch2paddle(module, save_dir, jit_type="trace", input_exampl
7474
> > - **save_dir** (str): 转换后模型保存路径
7575
> > - **jit_type** (str): 转换方式。目前有两种:trace和script, 默认为trace
7676
> > - **input_examples** (list[torch.tensor]): torch.nn. Module的输入示例,list的长度必须与输入的长度一致。默认为None
77-
> > - **enable_code_optim** (bool): 转换后的代码是否进行优化, 默认为True
77+
> > - **enable_code_optim** (bool): 转换后的代码是否进行优化, 默认为False
7878
> > - **convert_to_lite** (bool): 是否使用opt工具转成Paddle-Lite支持格式,默认为False
7979
> > - **lite_valid_places** (str): 指定转换类型,可以同时指定多个backend(以逗号分隔),opt将会自动选择最佳方式,默认为arm
8080
> > - **lite_model_type** (str): 指定模型转化类型,目前支持两种类型:protobuf和naive_buffer,默认为naive_buffer

x2paddle/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def arg_parser():
9393
parser.add_argument(
9494
"--enable_code_optim",
9595
"-co",
96-
default=True,
96+
default=False,
9797
help="Turn on code optimization")
9898
parser.add_argument(
9999
"--enable_onnx_checker",
@@ -329,7 +329,7 @@ def pytorch2paddle(module,
329329
save_dir,
330330
jit_type="trace",
331331
input_examples=None,
332-
enable_code_optim=True,
332+
enable_code_optim=False,
333333
convert_to_lite=False,
334334
lite_valid_places="arm",
335335
lite_model_type="naive_buffer",

x2paddle/core/program.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def update(layers):
260260

261261
return update(self.layers)
262262

263-
def gen_model(self, save_dir, jit_type=None, enable_code_optim=True):
263+
def gen_model(self, save_dir, jit_type=None, enable_code_optim=False):
264264
if not osp.exists(save_dir):
265265
os.makedirs(save_dir)
266266
if jit_type == "trace":

0 commit comments

Comments
 (0)