Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
527946df
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看板
提交
527946df
编写于
12月 07, 2018
作者:
T
tangwei12
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add scope in prefetch
上级
b653ed05
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
16 deletion
+31
-16
paddle/fluid/operators/distributed/parameter_prefetch.cc
paddle/fluid/operators/distributed/parameter_prefetch.cc
+10
-9
paddle/fluid/operators/lookup_table_op.h
paddle/fluid/operators/lookup_table_op.h
+2
-1
paddle/fluid/operators/nce_op.h
paddle/fluid/operators/nce_op.h
+19
-6
未找到文件。
paddle/fluid/operators/distributed/parameter_prefetch.cc
浏览文件 @
527946df
...
...
@@ -102,8 +102,9 @@ static void MergeMultipleVarsIntoOneBySection(
const
std
::
string
&
out_name
,
const
std
::
vector
<
std
::
string
>&
out_var_names
,
const
std
::
vector
<
int
>&
height_section
,
const
std
::
vector
<
std
::
vector
<
int64_t
>>&
splited_ids
,
const
framework
::
ExecutionContext
&
context
,
framework
::
Scope
*
scope
,
platform
::
DeviceContext
*
actual_ctx
)
{
const
framework
::
ExecutionContext
&
context
,
const
framework
::
Scope
&
actual_scope
,
framework
::
Scope
*
scope
,
platform
::
DeviceContext
*
actual_ctx
,
)
{
PADDLE_ENFORCE_EQ
(
out_var_names
.
size
(),
height_section
.
size
(),
""
);
auto
cpu_place
=
platform
::
CPUPlace
();
...
...
@@ -114,9 +115,9 @@ static void MergeMultipleVarsIntoOneBySection(
id_to_offset
[
ids_vector
[
i
]].
push_back
(
i
);
}
auto
&
id_tensor
=
scope
->
FindVar
(
id_name
)
->
Get
<
framework
::
LoDTensor
>
();
auto
&
id_tensor
=
actual_scope
.
FindVar
(
id_name
)
->
Get
<
framework
::
LoDTensor
>
();
auto
*
out_tensor
=
scope
->
FindVar
(
out_name
)
->
GetMutable
<
framework
::
LoDTensor
>
();
actual_scope
.
FindVar
(
out_name
)
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
*
out_tensor_data
=
out_tensor
->
mutable_data
<
float
>
(
id_tensor
.
place
());
bool
is_on_cpu_place
=
true
;
...
...
@@ -172,8 +173,9 @@ void prefetch(const std::string& id_name, const std::string& out_name,
const
std
::
vector
<
std
::
string
>&
table_names
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
int
>&
height_sections
,
const
framework
::
ExecutionContext
&
context
)
{
auto
&
local_scope
=
context
.
scope
().
NewScope
();
const
framework
::
ExecutionContext
&
context
,
const
framework
::
Scope
&
scope
)
{
auto
&
local_scope
=
scope
.
NewScope
();
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
&
cpu_ctx
=
*
pool
.
Get
(
platform
::
CPUPlace
());
...
...
@@ -245,9 +247,8 @@ void prefetch(const std::string& id_name, const std::string& out_name,
MergeMultipleVarsIntoOneBySection
(
id_name
,
ids_vector
,
out_name
,
out_var_names
,
height_sections
,
splited_ids
,
context
,
&
local_scope
,
&
actual_ctx
);
context
.
scope
().
DeleteScope
(
&
local_scope
);
context
,
scope
,
&
local_scope
,
&
actual_ctx
);
scope
.
DeleteScope
(
&
local_scope
);
}
};
// namespace distributed
...
...
paddle/fluid/operators/lookup_table_op.h
浏览文件 @
527946df
...
...
@@ -59,7 +59,8 @@ class LookupTableKernel : public framework::OpKernel<T> {
// server
#ifdef PADDLE_WITH_DISTRIBUTE
operators
::
distributed
::
prefetch
(
id_name
,
out_name
,
table_names
,
epmap
,
height_sections
,
context
);
height_sections
,
context
,
context
.
scope
());
#else
PADDLE_THROW
(
"paddle is not compiled with distribute support, can not do "
...
...
paddle/fluid/operators/nce_op.h
浏览文件 @
527946df
...
...
@@ -170,18 +170,31 @@ class NCEKernel : public framework::OpKernel<T> {
auto
height_sections
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"height_sections"
);
auto
table_names
=
context
.
Attr
<
std
::
vector
<
std
::
string
>>
(
"table_names"
);
local_scope
.
Var
(
"Ids"
);
local_scope
.
Var
(
"Weight"
);
auto
*
ids
=
local_scope
.
Var
(
"Ids"
);
auto
*
x_tensor
=
ids
->
GetMutable
<
framework
::
LoDTensor
>
();
x_tensor
->
mutable_data
<
int64_t
>
(
framework
::
make_ddim
({
static_cast
<
int64_t
>
(
labels
.
size
()),
1
}),
context
.
GetPlace
());
// copy.
std
::
memcpy
(
x_tensor
->
data
<
int64_t
>
(),
labels
.
data
(),
labels
.
size
()
*
sizeof
(
int64_t
));
local_scope
.
Var
(
"Weight@Local"
)
->
GetMutable
<
framework
::
Tensor
>
()
->
mutable_data
<
T
>
(
context
.
GetPlace
());
#ifdef PADDLE_WITH_DISTRIBUTE
operators
::
distributed
::
prefetch
(
"Ids"
,
"Weight"
,
table_names
,
epmap
,
height_sections
,
context
);
operators
::
distributed
::
prefetch
(
"Ids"
,
"Weight@Local"
,
table_names
,
epmap
,
height_sections
,
context
,
&
local_scope
);
#else
PADDLE_THROW
(
"paddle is not compiled with distribute support, can not do "
"parameter prefetch!"
);
#endif
auto
weight_mat
=
EigenMatrix
<
T
>::
From
(
*
(
weight
->
Get
<
T
>
()));
auto
weight_mat
=
EigenMatrix
<
T
>::
From
(
(
local_scope
.
Var
(
"Weight@Local"
)
->
Get
<
framework
::
Tensor
>
()));
for
(
int64_t
i
=
0
;
i
<
sample_labels
->
numel
();
++
i
)
{
std
::
vector
<
int64_t
>::
iterator
it
=
std
::
find
(
labels
.
begin
(),
labels
.
end
(),
sample_labels_data
[
i
]);
...
...
@@ -196,7 +209,7 @@ class NCEKernel : public framework::OpKernel<T> {
}
context
.
scope
().
DeleteScope
(
&
local_scope
);
#endif
}
else
{
auto
weight_mat
=
EigenMatrix
<
T
>::
From
(
*
(
context
.
Input
<
Tensor
>
(
"Weight"
)));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录