Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6edbf138
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6edbf138
编写于
1月 17, 2018
作者:
K
Kexin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove ptools
上级
e1f475ad
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
4 addition
and
35 deletion
+4
-35
paddle/inference/CMakeLists.txt
paddle/inference/CMakeLists.txt
+0
-21
paddle/inference/inference.cc
paddle/inference/inference.cc
+1
-10
python/paddle/v2/fluid/io.py
python/paddle/v2/fluid/io.py
+3
-4
未找到文件。
paddle/inference/CMakeLists.txt
浏览文件 @
6edbf138
...
@@ -8,27 +8,6 @@ cc_library(paddle_fluid_api
...
@@ -8,27 +8,6 @@ cc_library(paddle_fluid_api
# Merge all modules into a simgle static library
# Merge all modules into a simgle static library
cc_library
(
paddle_fluid DEPS paddle_fluid_api
${
FLUID_CORE_MODULES
}
)
cc_library
(
paddle_fluid DEPS paddle_fluid_api
${
FLUID_CORE_MODULES
}
)
# ptools
# just for testing, we may need to change the storing format for inference_model
# and move the dependent of pickle.
# download from http://www.picklingtools.com/
# build in the C++ sub-directory, using command
# make -f Makefile.Linux libptools.so
set
(
PTOOLS_LIB
)
set
(
PTOOLS_ROOT $ENV{PTOOLS_ROOT} CACHE PATH
"Folder contains PicklingTools"
)
find_path
(
PTOOLS_INC_DIR chooseser.h PATHS
${
PTOOLS_ROOT
}
/C++
)
find_library
(
PTOOLS_SHARED_LIB NAMES ptools PATHS
${
PTOOLS_ROOT
}
/C++
)
if
(
PTOOLS_INC_DIR AND PTOOLS_SHARED_LIB
)
add_definitions
(
-DPADDLE_USE_PTOOLS
)
set
(
PTOOLS_LIB ptools
)
message
(
STATUS
"Found PicklingTools:
${
PTOOLS_SHARED_LIB
}
"
)
add_library
(
${
PTOOLS_LIB
}
SHARED IMPORTED GLOBAL
)
set_property
(
TARGET
${
PTOOLS_LIB
}
PROPERTY IMPORTED_LOCATION
${
PTOOLS_SHARED_LIB
}
)
include_directories
(
${
PTOOLS_ROOT
}
/C++
)
include_directories
(
${
PTOOLS_ROOT
}
/C++/opencontainers_1_8_5/include
)
add_definitions
(
-DOC_NEW_STYLE_INCLUDES
)
# used in ptools
endif
()
add_executable
(
example example.cc
)
add_executable
(
example example.cc
)
if
(
APPLE
)
if
(
APPLE
)
set
(
OPTIONAL_LINK_FLAGS
)
set
(
OPTIONAL_LINK_FLAGS
)
...
...
paddle/inference/inference.cc
浏览文件 @
6edbf138
...
@@ -56,15 +56,6 @@ void InferenceEngine::LoadInferenceModel(
...
@@ -56,15 +56,6 @@ void InferenceEngine::LoadInferenceModel(
const
std
::
string
&
dirname
,
const
std
::
string
&
dirname
,
const
std
::
vector
<
std
::
string
>&
feed_var_names
,
const
std
::
vector
<
std
::
string
>&
feed_var_names
,
const
std
::
vector
<
std
::
string
>&
fetch_var_names
)
{
const
std
::
vector
<
std
::
string
>&
fetch_var_names
)
{
#ifdef PADDLE_USE_PTOOLS
std
::
string
model_filename
=
dirname
+
"/__model__"
;
LOG
(
INFO
)
<<
"Using PicklingTools, loading model from "
<<
model_filename
;
Val
v
;
LoadValFromFile
(
model_filename
.
c_str
(),
v
,
SERIALIZE_P0
);
std
::
string
program_desc_str
=
v
[
"program_desc_str"
];
LOG
(
INFO
)
<<
"program_desc_str's size: "
<<
program_desc_str
.
size
();
// PicklingTools cannot parse the vector of strings correctly.
#else
std
::
string
model_filename
=
dirname
+
"/__model__.dat"
;
std
::
string
model_filename
=
dirname
+
"/__model__.dat"
;
LOG
(
INFO
)
<<
"loading model from "
<<
model_filename
;
LOG
(
INFO
)
<<
"loading model from "
<<
model_filename
;
std
::
ifstream
inputfs
(
model_filename
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
ifstream
inputfs
(
model_filename
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
...
@@ -75,7 +66,7 @@ void InferenceEngine::LoadInferenceModel(
...
@@ -75,7 +66,7 @@ void InferenceEngine::LoadInferenceModel(
LOG
(
INFO
)
<<
"program_desc_str's size: "
<<
program_desc_str
.
size
();
LOG
(
INFO
)
<<
"program_desc_str's size: "
<<
program_desc_str
.
size
();
inputfs
.
read
(
&
program_desc_str
[
0
],
program_desc_str
.
size
());
inputfs
.
read
(
&
program_desc_str
[
0
],
program_desc_str
.
size
());
inputfs
.
close
();
inputfs
.
close
();
#endif
program_
=
new
framework
::
ProgramDesc
(
program_desc_str
);
program_
=
new
framework
::
ProgramDesc
(
program_desc_str
);
GenerateLoadProgram
(
dirname
);
GenerateLoadProgram
(
dirname
);
...
...
python/paddle/v2/fluid/io.py
浏览文件 @
6edbf138
...
@@ -198,11 +198,10 @@ def prepend_feed_ops(inference_program, feeded_var_names):
...
@@ -198,11 +198,10 @@ def prepend_feed_ops(inference_program, feeded_var_names):
name
=
'feed'
,
type
=
core
.
VarDesc
.
VarType
.
FEED_MINIBATCH
,
persistable
=
True
)
name
=
'feed'
,
type
=
core
.
VarDesc
.
VarType
.
FEED_MINIBATCH
,
persistable
=
True
)
for
i
,
name
in
enumerate
(
feeded_var_names
):
for
i
,
name
in
enumerate
(
feeded_var_names
):
out
=
global_block
.
var
(
name
)
global_block
.
prepend_op
(
global_block
.
prepend_op
(
type
=
'feed'
,
type
=
'feed'
,
inputs
=
{
'X'
:
[
feed_var
]},
inputs
=
{
'X'
:
[
feed_var
]},
outputs
=
{
'Out'
:
[
out
]},
outputs
=
{
'Out'
:
[
name
]},
attrs
=
{
'col'
:
i
})
attrs
=
{
'col'
:
i
})
...
@@ -269,11 +268,11 @@ def save_inference_model(dirname,
...
@@ -269,11 +268,11 @@ def save_inference_model(dirname,
"fetch_var_names"
:
fetch_var_names
"fetch_var_names"
:
fetch_var_names
},
f
,
-
1
)
},
f
,
-
1
)
# Save only programDesc of inference_program in binary format
# in another file: __model__.dat
prepend_feed_ops
(
inference_program
,
feeded_var_names
)
prepend_feed_ops
(
inference_program
,
feeded_var_names
)
append_fetch_ops
(
inference_program
,
fetch_var_names
)
append_fetch_ops
(
inference_program
,
fetch_var_names
)
# Save only programDesc of inference_program in binary format
# in another file: __model__.dat
with
open
(
model_file_name
+
".dat"
,
"wb"
)
as
fp
:
with
open
(
model_file_name
+
".dat"
,
"wb"
)
as
fp
:
fp
.
write
(
inference_program
.
desc
.
serialize_to_string
())
fp
.
write
(
inference_program
.
desc
.
serialize_to_string
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录