Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c46cecd7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
c46cecd7
编写于
11月 20, 2018
作者:
W
wangguibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Creating DataFeedDesc from .proto file, then manipulate it (add/del fields etc) from python side
上级
91fc8f35
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
34 addition
and
28 deletion
+34
-28
paddle/fluid/framework/CMakeLists.txt
paddle/fluid/framework/CMakeLists.txt
+1
-1
paddle/fluid/framework/async_executor.cc
paddle/fluid/framework/async_executor.cc
+3
-1
paddle/fluid/framework/async_executor.h
paddle/fluid/framework/async_executor.h
+1
-1
paddle/fluid/framework/data_feed.proto
paddle/fluid/framework/data_feed.proto
+12
-1
paddle/fluid/pybind/async_executor_py.cc
paddle/fluid/pybind/async_executor_py.cc
+0
-11
python/paddle/fluid/async_executor.py
python/paddle/fluid/async_executor.py
+17
-13
未找到文件。
paddle/fluid/framework/CMakeLists.txt
浏览文件 @
c46cecd7
...
@@ -146,7 +146,7 @@ cc_library(op_registry SRCS op_registry.cc DEPS op_proto_maker op_info operator
...
@@ -146,7 +146,7 @@ cc_library(op_registry SRCS op_registry.cc DEPS op_proto_maker op_info operator
nv_test
(
op_registry_test SRCS op_registry_test.cc DEPS op_registry
)
nv_test
(
op_registry_test SRCS op_registry_test.cc DEPS op_registry
)
if
(
NOT WIN32
)
if
(
NOT WIN32
)
py_proto_compile
(
framework_py_proto SRCS framework.proto
)
py_proto_compile
(
framework_py_proto SRCS framework.proto
data_feed.proto
)
# Generate an empty __init__.py to make framework_py_proto as a valid python module.
# Generate an empty __init__.py to make framework_py_proto as a valid python module.
add_custom_target
(
framework_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_custom_target
(
framework_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_dependencies
(
framework_py_proto framework_py_proto_init
)
add_dependencies
(
framework_py_proto framework_py_proto_init
)
...
...
paddle/fluid/framework/async_executor.cc
浏览文件 @
c46cecd7
...
@@ -139,12 +139,14 @@ void AsyncExecutor::SetModelPrefix(const std::string& model_prefix) {
...
@@ -139,12 +139,14 @@ void AsyncExecutor::SetModelPrefix(const std::string& model_prefix) {
std
::
vector
<
float
>
AsyncExecutor
::
RunFromFile
(
std
::
vector
<
float
>
AsyncExecutor
::
RunFromFile
(
const
ProgramDesc
&
main_program
,
const
ProgramDesc
&
main_program
,
const
DataFeedDesc
&
data_feed_desc
,
const
std
::
string
&
data_feed_desc_str
,
const
std
::
vector
<
std
::
string
>&
filelist
,
const
std
::
vector
<
std
::
string
>&
filelist
,
const
int
thread_num
,
const
int
thread_num
,
const
std
::
vector
<
std
::
string
>&
fetch_var_names
)
{
const
std
::
vector
<
std
::
string
>&
fetch_var_names
)
{
std
::
vector
<
std
::
thread
>
threads
;
std
::
vector
<
std
::
thread
>
threads
;
DataFeedDesc
data_feed_desc
;
google
::
protobuf
::
TextFormat
::
ParseFromString
(
data_feed_desc_str
,
&
data_feed_desc
);
/*
/*
readerDesc: protobuf description for reader initlization
readerDesc: protobuf description for reader initlization
argument: class_name, batch_size, use_slot, queue_size, buffer_size, padding_index
argument: class_name, batch_size, use_slot, queue_size, buffer_size, padding_index
...
...
paddle/fluid/framework/async_executor.h
浏览文件 @
c46cecd7
...
@@ -55,7 +55,7 @@ class AsyncExecutor {
...
@@ -55,7 +55,7 @@ class AsyncExecutor {
void
SetModelPrefix
(
const
std
::
string
&
model_prefix
);
void
SetModelPrefix
(
const
std
::
string
&
model_prefix
);
void
RunStartupProgram
(
const
ProgramDesc
&
program
,
Scope
*
scope
);
void
RunStartupProgram
(
const
ProgramDesc
&
program
,
Scope
*
scope
);
std
::
vector
<
float
>
RunFromFile
(
const
ProgramDesc
&
main_program
,
std
::
vector
<
float
>
RunFromFile
(
const
ProgramDesc
&
main_program
,
const
DataFeedDesc
&
data_feed_desc
,
const
std
::
string
&
data_feed_desc_str
,
const
std
::
vector
<
std
::
string
>&
filelist
,
const
std
::
vector
<
std
::
string
>&
filelist
,
const
int
thread_num
,
const
int
thread_num
,
const
std
::
vector
<
std
::
string
>&
fetch_names
);
const
std
::
vector
<
std
::
string
>&
fetch_names
);
...
...
paddle/fluid/framework/data_feed.proto
浏览文件 @
c46cecd7
...
@@ -17,6 +17,17 @@ package paddle.framework;
...
@@ -17,6 +17,17 @@ package paddle.framework;
message
DataFeedDesc
{
message
DataFeedDesc
{
optional
string
name
=
1
;
optional
string
name
=
1
;
optional
int32
batch
=
2
[
default
=
32
];
optional
int32
batch
=
2
[
default
=
32
];
repeated
string
field_names
=
3
;
optional
MultiSlotDesc
multi_slot_desc
=
3
;
}
message
MultiSlotDesc
{
repeated
Slot
slots
=
1
;
}
message
Slot
{
required
string
name
=
1
;
required
string
type
=
2
;
optional
bool
dense
=
3
[
default
=
false
];
optional
bool
use
=
4
[
default
=
true
];
}
}
paddle/fluid/pybind/async_executor_py.cc
浏览文件 @
c46cecd7
...
@@ -41,17 +41,6 @@ namespace paddle {
...
@@ -41,17 +41,6 @@ namespace paddle {
namespace
pybind
{
namespace
pybind
{
using
set_name_func
=
void
(
pd
::
DataFeedDesc
::*
)(
const
std
::
string
&
);
using
set_name_func
=
void
(
pd
::
DataFeedDesc
::*
)(
const
std
::
string
&
);
void
BindAsyncExecutor
(
py
::
module
*
m
)
{
void
BindAsyncExecutor
(
py
::
module
*
m
)
{
py
::
class_
<
pd
::
DataFeedDesc
>
(
*
m
,
"DataFeedDesc"
)
.
def
(
pybind11
::
init
<>
())
.
def
(
"set_name"
,
(
set_name_func
)
&
pd
::
DataFeedDesc
::
set_name
)
.
def
(
"set_batch"
,
&
pd
::
DataFeedDesc
::
set_batch
)
.
def
(
"set_field_names"
,
[]
(
pd
::
DataFeedDesc
&
self
,
const
std
::
vector
<
std
::
string
>
&
fields
)
{
for
(
auto
field
:
fields
)
{
self
.
add_field_names
(
field
);
}
});
py
::
class_
<
framework
::
AsyncExecutor
>
(
*
m
,
"AsyncExecutor"
)
py
::
class_
<
framework
::
AsyncExecutor
>
(
*
m
,
"AsyncExecutor"
)
.
def
(
py
::
init
<
pd
::
Scope
&
,
const
platform
::
Place
&>
())
.
def
(
py
::
init
<
pd
::
Scope
&
,
const
platform
::
Place
&>
())
.
def
(
"run_from_files"
,
&
framework
::
AsyncExecutor
::
RunFromFile
)
.
def
(
"run_from_files"
,
&
framework
::
AsyncExecutor
::
RunFromFile
)
...
...
python/paddle/fluid/async_executor.py
浏览文件 @
c46cecd7
...
@@ -20,25 +20,29 @@ import six
...
@@ -20,25 +20,29 @@ import six
from
.framework
import
Program
,
default_main_program
,
Variable
from
.framework
import
Program
,
default_main_program
,
Variable
from
.
import
core
from
.
import
core
from
.executor
import
global_scope
from
.executor
import
global_scope
from
paddle.fluid.proto
import
data_feed_pb2
from
google.protobuf
import
text_format
__all__
=
[
'
MultiSlotDataFeed
'
,
'AsyncExecutor'
]
__all__
=
[
'
DataFeedDesc
'
,
'AsyncExecutor'
]
g_scope
=
core
.
Scope
()
g_scope
=
core
.
Scope
()
class
DataFeedDesc
(
object
):
class
DataFeedDesc
(
object
):
def
__init__
(
self
):
def
__init__
(
self
,
proto_file
):
self
.
desc
=
core
.
DataFeedDesc
()
self
.
proto_desc
=
data_feed_pb2
.
DataFeedDesc
()
f
=
open
(
proto_file
,
'r'
)
text_format
.
Parse
(
f
.
read
(),
self
.
proto_desc
)
f
.
close
()
def
set_batch_size
(
self
,
batch_size
):
def
set_batch_size
(
self
,
batch_size
):
self
.
desc
.
set_batch
(
batch_size
)
self
.
proto_desc
.
batch
=
batch_size
def
set_field_name
(
self
,
field_names
):
if
isinstance
(
field_names
,
str
):
def
add_slot
(
self
):
field_names
=
[
field_names
]
slot
=
self
.
proto_desc
.
multi_slot_desc
.
slots
.
add
()
self
.
desc
.
set_field_names
(
field_names
)
return
slot
class
MultiSlotDataFeed
(
DataFeedDesc
):
def
desc
(
self
):
def
__init__
(
self
):
return
text_format
.
MessageToString
(
self
.
proto_desc
)
super
(
MultiSlotDataFeed
,
self
).
__init__
()
self
.
desc
.
set_name
(
"MultiSlotDataFeed"
)
class
AsyncExecutor
(
object
):
class
AsyncExecutor
(
object
):
"""
"""
...
@@ -127,6 +131,6 @@ class AsyncExecutor(object):
...
@@ -127,6 +131,6 @@ class AsyncExecutor(object):
fetch
=
[
fetch
]
fetch
=
[
fetch
]
fetch_var_names
=
[
var
.
name
for
var
in
fetch
]
fetch_var_names
=
[
var
.
name
for
var
in
fetch
]
evaluation
=
self
.
executor
.
run_from_files
(
program_desc
,
data_feed
.
desc
,
filelist
,
thread_num
,
fetch_var_names
)
evaluation
=
self
.
executor
.
run_from_files
(
program_desc
,
data_feed
,
filelist
,
thread_num
,
fetch_var_names
)
return
evaluation
return
evaluation
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录