diff --git a/docs/demo_guides/python_demo.md b/docs/demo_guides/python_demo.md index 24ce217e57684791e5bce3cf8b1295faf7740c45..4370a6fbbfb95e68b131cc4bb1a7d51877938655 100644 --- a/docs/demo_guides/python_demo.md +++ b/docs/demo_guides/python_demo.md @@ -27,12 +27,19 @@ tar zxf mobilenet_v1.tar.gz - 非combined形式:模型文件夹model_dir下存在一个模型文件和多个参数文件时,传入模型文件夹路径,模型文件名默认为__model__。 ```shell - paddle_lite_opt --model_dir=./mobilenet_v1 --valid_targets=mobilenet_v1_opt --valid_targets=x86 + paddle_lite_opt --model_dir=./mobilenet_v1 \ + --optimize_out=mobilenet_v1_opt \ + --optimize_out_type=naive_buffer \ + --valid_targets=x86 ``` - combined形式:模型文件夹model_dir下只有一个模型文件__model__和一个参数文件__params__时,传入模型文件和参数文件路径 ```shell - paddle_lite_opt --model_file=./mobilenet_v1/__model__ --param_file=./mobilenet_v1/__params__ --valid_targets=mobilenet_v1_opt --valid_targets=x86 + paddle_lite_opt --model_file=./mobilenet_v1/__model__ \ + --param_file=./mobilenet_v1/__params__ \ + --optimize_out=mobilenet_v1_opt \ + --optimize_out_type=naive_buffer \ + --valid_targets=x86 ``` - windows环境 diff --git a/docs/demo_guides/x86.md b/docs/demo_guides/x86.md index a8a4c117b69d401a7630edc231736e1bd74ba89f..d551daa8925e9eb2c0d0608830dab8795f5323c8 100644 --- a/docs/demo_guides/x86.md +++ b/docs/demo_guides/x86.md @@ -209,9 +209,9 @@ git checkout release/v2.6.0 ``` 2、 源码编译(需要按照提示输入对应的参数) -```bash +```dos cd Paddle-Lite -lite/tools/build_windows.bat +lite\tools\build_windows.bat ``` ### 编译结果说明 @@ -269,8 +269,8 @@ build.bat cd build ``` 编译结果为当前目录下的 `Release\mobilenet_full_api.exe ` -``` bash +``` dos # 2、执行预测 -Release\\mobilenet_full_api.exe mobilenet_v1 +Release\mobilenet_full_api.exe mobilenet_v1 ``` 下载并解压模型[`mobilenet_v1`](http://paddle-inference-dist.bj.bcebos.com/mobilenet_v1.tar.gz)到`build`目录,执行以上命令进行预测。 diff --git a/lite/model_parser/model_parser.cc b/lite/model_parser/model_parser.cc index 8bf3f87c613de261b5c4da9a1ab55c4378082864..77c7543d6be778e3763220f3d30a0c58ffc2fdde 100644 --- a/lite/model_parser/model_parser.cc +++ b/lite/model_parser/model_parser.cc @@ -323,7 +323,7 @@ void SaveCombinedParamsPb(const std::string &path, std::sort(paramlist.begin(), paramlist.end()); // Load vars - std::ofstream file(path); + std::ofstream file(path, std::ios::binary); CHECK(file.is_open()); for (size_t i = 0; i < paramlist.size(); ++i) { SerializeTensor(file, exec_scope, paramlist[i]); diff --git a/lite/utils/io.h b/lite/utils/io.h index 92405cae862f062090665aecc8eb7f207cf059e7..506901bad5f75c5c1564f6340c7f687537de2e68 100644 --- a/lite/utils/io.h +++ b/lite/utils/io.h @@ -38,10 +38,17 @@ static bool IsFileExists(const std::string& path) { // ARM mobile not support mkdir in C++ static void MkDirRecur(const std::string& path) { #ifndef LITE_WITH_ARM + +#ifdef _WIN32 + if (system(string_format("md %s", path.c_str()).c_str()) != 0) { + LOG(ERROR) << "Cann't mkdir " << path; + } +#else if (system(string_format("mkdir -p %s", path.c_str()).c_str()) != 0) { LOG(ERROR) << "Cann't mkdir " << path; } -#else // On ARM +#endif // _WIN32 +#else // On ARM CHECK_NE(mkdir(path.c_str(), S_IRWXU), -1) << "Cann't mkdir " << path; #endif }