Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b57c0bf5
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看板
提交
b57c0bf5
编写于
11月 13, 2018
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clear async executor interface and add data feed factory
上级
38798281
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
114 addition
and
5 deletion
+114
-5
paddle/fluid/framework/async_executor_refactor.cc
paddle/fluid/framework/async_executor_refactor.cc
+7
-0
paddle/fluid/framework/async_executor_refactor.h
paddle/fluid/framework/async_executor_refactor.h
+16
-5
paddle/fluid/framework/data_feed_factory.cc
paddle/fluid/framework/data_feed_factory.cc
+60
-0
paddle/fluid/framework/data_feed_factory.h
paddle/fluid/framework/data_feed_factory.h
+31
-0
未找到文件。
paddle/fluid/framework/async_executor_refactor.cc
浏览文件 @
b57c0bf5
...
...
@@ -194,6 +194,13 @@ void AsyncExecutor::CreateThreads(const ExecutorThreadWorker* worker,
worker
->
SetRootScope
(
root_scope
);
}
shared_ptr
<
DataFeed
>
AsyncExecutor
::
CreateDataFeed
(
const
char
*
feed_name
)
{
if
(
g_datafeed_map
.
count
(
string
(
feed_name
))
<
1
)
{
return
NULL
;
}
return
g_datafeed_map
[
feed_name
]();
}
void
AsyncExecutor
::
CheckFiles
(
const
std
::
vector
<
std
::
string
>&
files
)
{
// function for user to check file formats
...
...
paddle/fluid/framework/async_executor_refactor.h
浏览文件 @
b57c0bf5
...
...
@@ -36,25 +36,35 @@ class ExecutorThreadWorker {
public:
ExecutorThreadWorker
()
{}
~
ExecutorThreadWorker
()
{}
/**
* Create thread level scope which is a child of root scope
*/
void
CreateThreadScope
(
const
framework
::
ProgramDesc
&
program
);
void
SetDataFeed
(
const
DataFeed
&
datafeed
);
void
SetThreadId
(
int
tid
);
/**
* Create
*/
void
CreateThreadOperators
(
const
framework
::
ProgramDesc
&
program
);
/**
* Set current root scope
*/
void
SetRootScope
(
Scope
*
g_scope
);
void
SetDevice
();
void
SetMainProgram
(
const
ProgramDesc
&
main_program_desc
);
void
SetPlace
(
const
paddle
::
platform
::
Place
&
place
);
/**
* current DataFeed is defined in class
**/
void
BindingDataFeedMemory
();
void
SetSparseCommData
(
const
std
::
map
<
std
::
string
,
int
>&
param_names
);
void
SetDataFeed
(
const
std
::
shared_ptr
<
DataFeed
>&
datafeed
);
protected:
// thread index
std
::
shared_ptr
<
DataFeed
>
thread_reader_
;
// shared queue, thread buffer
int
thread_id_
;
// op name
// op
erator
name
std
::
vector
<
std
::
string
>
op_names_
;
//
local op
s for forward and backward
//
thread level, local operator
s for forward and backward
std
::
vector
<
OperatorBase
*>
ops_
;
// main program for training
std
::
unique_ptr
<
framework
::
ProgramDesc
>
main_program_
;
...
...
@@ -72,7 +82,8 @@ class AsyncExecutor {
virtual
~
AsyncExecutor
()
{}
void
SetRootScope
(
const
Scope
*
root_scope
);
Scope
*
GetRootScope
()
{
return
root_scope_
;
}
void
CheckFiles
(
const
std
::
vector
<
std
::
string
>&
files
);
void
CheckFiles
(
const
std
::
vector
<
std
::
string
>&
files
);
void
RunFromFiles
(
const
ProgramDesc
&
main_program
,
const
std
::
vector
<
std
::
string
>&
files
,
...
...
paddle/fluid/framework/data_feed_factory.cc
0 → 100644
浏览文件 @
b57c0bf5
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/framework/data_feed_factory.h"
namespace
paddle
{
namespace
framework
{
typedef
shared_ptr
<
DataFeed
>
(
*
Createdata_feedFunction
)();
typedef
std
::
unordered_map
<
std
::
string
,
Createdata_feedFunction
>
data_feedMap
;
data_feedMap
g_data_feed_map
;
#define REGISTER_DATAFEED_CLASS(data_feed_class) \
namespace { \
shared_ptr<DataFeed> Creator_##data_feed_class() { \
return shared_ptr<DataFeed>(new data_feed_class); \
} \
class __Registerer_##data_feed_class { \
public: \
__Registerer_##data_feed_class() { \
g_data_feed_map[#data_feed_class] = &Creator_##data_feed_class; \
} \
}; \
__Registerer_##data_feed_class g_registerer_##data_feed_class; \
} // namespace
string
DataFeedFactory
::
DataFeedTypeList
()
{
string
data_feed_types
;
for
(
auto
iter
=
g_data_feed_map
.
begin
();
iter
!=
g_data_feed_map
.
end
();
++
iter
)
{
if
(
iter
!=
g_data_feed_map
.
begin
())
{
data_feed_types
+=
", "
;
}
data_feed_types
+=
iter
->
first
;
}
return
data_feed_types
;
}
shared_ptr
<
DataFeed
>
DataFeedFactory
::
CreateDataFeed
(
const
char
*
data_feed_class
)
{
if
(
g_data_feed_map
.
count
(
string
(
data_feed_class
))
<
1
)
{
exit
(
-
1
);
}
return
g_data_feed_map
[
data_feed_class
]();
}
REGISTER_DATAFEED_CLASS
(
MultiSlotDataFeed
);
}
// namespace framework
}
// namespace paddle
paddle/fluid/framework/data_feed_factory.h
0 → 100644
浏览文件 @
b57c0bf5
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifndef PADDLE_FLUID_FRAMEWORK_DATA_FEED_FACTORY_H_
#define PADDLE_FLUID_FRAMEWORK_DATA_FEED_FACTORY_H_
#include <string>
#include "paddle/framework/data_feed.h"
namespace
paddle
{
namespace
framework
{
class
DataFeedFactory
{
public:
static
std
::
string
DataFeedTypeList
();
static
shared_ptr
<
DataFeed
>
CreateDataFeed
(
const
char
*
data_feed_class
);
};
}
// namespace framework
}
// namespace paddle
#endif // PADDLE_FLUID_FRAMEWORK_DATA_FEED_FACTORY_H_
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录