未验证 提交 73c128b4 编写于 作者: S silingtong123 提交者: GitHub

fix the demo of opt saved can't work on windows (#3686)

fix the demo of opt saved can't work on windows

 fix the doc
上级 de017be4
...@@ -27,12 +27,19 @@ tar zxf mobilenet_v1.tar.gz ...@@ -27,12 +27,19 @@ tar zxf mobilenet_v1.tar.gz
- 非combined形式:模型文件夹model_dir下存在一个模型文件和多个参数文件时,传入模型文件夹路径,模型文件名默认为__model__。 - 非combined形式:模型文件夹model_dir下存在一个模型文件和多个参数文件时,传入模型文件夹路径,模型文件名默认为__model__。
```shell ```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__时,传入模型文件和参数文件路径 - combined形式:模型文件夹model_dir下只有一个模型文件__model__和一个参数文件__params__时,传入模型文件和参数文件路径
```shell ```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环境 - windows环境
......
...@@ -209,9 +209,9 @@ git checkout release/v2.6.0 ...@@ -209,9 +209,9 @@ git checkout release/v2.6.0
``` ```
2、 源码编译(需要按照提示输入对应的参数) 2、 源码编译(需要按照提示输入对应的参数)
```bash ```dos
cd Paddle-Lite cd Paddle-Lite
lite/tools/build_windows.bat lite\tools\build_windows.bat
``` ```
### 编译结果说明 ### 编译结果说明
...@@ -269,8 +269,8 @@ build.bat ...@@ -269,8 +269,8 @@ build.bat
cd build cd build
``` ```
编译结果为当前目录下的 `Release\mobilenet_full_api.exe ` 编译结果为当前目录下的 `Release\mobilenet_full_api.exe `
``` bash ``` dos
# 2、执行预测 # 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`目录,执行以上命令进行预测。 下载并解压模型[`mobilenet_v1`](http://paddle-inference-dist.bj.bcebos.com/mobilenet_v1.tar.gz)`build`目录,执行以上命令进行预测。
...@@ -323,7 +323,7 @@ void SaveCombinedParamsPb(const std::string &path, ...@@ -323,7 +323,7 @@ void SaveCombinedParamsPb(const std::string &path,
std::sort(paramlist.begin(), paramlist.end()); std::sort(paramlist.begin(), paramlist.end());
// Load vars // Load vars
std::ofstream file(path); std::ofstream file(path, std::ios::binary);
CHECK(file.is_open()); CHECK(file.is_open());
for (size_t i = 0; i < paramlist.size(); ++i) { for (size_t i = 0; i < paramlist.size(); ++i) {
SerializeTensor(file, exec_scope, paramlist[i]); SerializeTensor(file, exec_scope, paramlist[i]);
......
...@@ -38,10 +38,17 @@ static bool IsFileExists(const std::string& path) { ...@@ -38,10 +38,17 @@ static bool IsFileExists(const std::string& path) {
// ARM mobile not support mkdir in C++ // ARM mobile not support mkdir in C++
static void MkDirRecur(const std::string& path) { static void MkDirRecur(const std::string& path) {
#ifndef LITE_WITH_ARM #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) { if (system(string_format("mkdir -p %s", path.c_str()).c_str()) != 0) {
LOG(ERROR) << "Cann't mkdir " << path; 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; CHECK_NE(mkdir(path.c_str(), S_IRWXU), -1) << "Cann't mkdir " << path;
#endif #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册