Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
5b3cf4ee
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5b3cf4ee
编写于
1月 03, 2018
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use gflags to parse arguments from command-line.
上级
42a0603e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
10 deletion
+32
-10
paddle/inference/example.cc
paddle/inference/example.cc
+32
-9
paddle/inference/inference.cc
paddle/inference/inference.cc
+0
-1
未找到文件。
paddle/inference/example.cc
浏览文件 @
5b3cf4ee
...
...
@@ -14,16 +14,37 @@ limitations under the License. */
#include <time.h>
#include <iostream>
#include "gflags/gflags.h"
#include "paddle/inference/inference.h"
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
string
dirname
=
"/home/work/liuyiqun/PaddlePaddle/Paddle/paddle/inference/"
"recognize_digits_mlp.inference.model"
;
std
::
vector
<
std
::
string
>
feed_var_names
=
{
"x"
};
std
::
vector
<
std
::
string
>
fetch_var_names
=
{
"fc_2.tmp_2"
};
paddle
::
InferenceEngine
*
desc
=
new
paddle
::
InferenceEngine
();
desc
->
LoadInferenceModel
(
dirname
,
feed_var_names
,
fetch_var_names
);
DEFINE_string
(
dirname
,
""
,
"Directory of the inference model."
);
DEFINE_string
(
feed_var_names
,
""
,
"Names of feeding variables"
);
DEFINE_string
(
fetch_var_names
,
""
,
"Names of fetching variables"
);
int
main
(
int
argc
,
char
**
argv
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
if
(
FLAGS_dirname
.
empty
()
||
FLAGS_feed_var_names
.
empty
()
||
FLAGS_fetch_var_names
.
empty
())
{
// Example:
// ./example --dirname=recognize_digits_mlp.inference.model
// --feed_var_names="x"
// --fetch_var_names="fc_2.tmp_2"
std
::
cout
<<
"Usage: ./example --dirname=path/to/your/model "
"--feed_var_names=x --fetch_var_names=y"
<<
std
::
endl
;
exit
(
1
);
}
std
::
cout
<<
"FLAGS_dirname: "
<<
FLAGS_dirname
<<
std
::
endl
;
std
::
cout
<<
"FLAGS_feed_var_names: "
<<
FLAGS_feed_var_names
<<
std
::
endl
;
std
::
cout
<<
"FLAGS_fetch_var_names: "
<<
FLAGS_fetch_var_names
<<
std
::
endl
;
std
::
string
dirname
=
FLAGS_dirname
;
std
::
vector
<
std
::
string
>
feed_var_names
=
{
FLAGS_feed_var_names
};
std
::
vector
<
std
::
string
>
fetch_var_names
=
{
FLAGS_fetch_var_names
};
paddle
::
InferenceEngine
*
engine
=
new
paddle
::
InferenceEngine
();
engine
->
LoadInferenceModel
(
dirname
,
feed_var_names
,
fetch_var_names
);
paddle
::
framework
::
LoDTensor
input
;
srand
(
time
(
0
));
...
...
@@ -36,7 +57,7 @@ int main(int argc, char* argv[]) {
std
::
vector
<
paddle
::
framework
::
LoDTensor
>
feeds
;
feeds
.
push_back
(
input
);
std
::
vector
<
paddle
::
framework
::
LoDTensor
>
fetchs
;
desc
->
Execute
(
feeds
,
fetchs
);
engine
->
Execute
(
feeds
,
fetchs
);
for
(
size_t
i
=
0
;
i
<
fetchs
.
size
();
++
i
)
{
auto
dims_i
=
fetchs
[
i
].
dims
();
...
...
@@ -52,5 +73,7 @@ int main(int argc, char* argv[]) {
}
std
::
cout
<<
std
::
endl
;
}
delete
engine
;
return
0
;
}
paddle/inference/inference.cc
浏览文件 @
5b3cf4ee
...
...
@@ -94,7 +94,6 @@ void InferenceEngine::GenerateLoadProgram(const std::string& dirname) {
if
(
IsParameter
(
var
))
{
LOG
(
INFO
)
<<
"parameter's name: "
<<
var
->
Name
();
// framework::VarDesc new_var = *var;
framework
::
VarDesc
*
new_var
=
load_block
->
Var
(
var
->
Name
());
new_var
->
SetShape
(
var
->
Shape
());
new_var
->
SetDataType
(
var
->
GetDataType
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录