diff --git a/README.md b/README.md index b0f6dfe38f2fac0257f2b595645c3eee365e5b2d..df597287c478fa151e8de7bae7e97f7841a145d9 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 2fc49d348fe0aed6717f3764d6b254f31b1fa73d..d1f0248b1681e90d95944428e736ced8f4f24849 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 c6ee37d7724dfaa3cad22fc1eb81d8a9050c97e4..ff56f4a33b05e18bba5605d40dc3b7447ecf0d9e 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 a14a0af1a98b96992ba3e773a3dd3889b3f86919..336feb36e32c70acb543edb9f193d47262750739 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 7d1ba96cc034bc3182fc820af2ed322c729c3130..7b88864cae222a52a774e3f20daf94372234a095 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":