Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
ea0df4e8
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看板
提交
ea0df4e8
编写于
3月 16, 2019
作者:
Q
Qiao Longfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some check
上级
065b68b6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
15 deletion
+13
-15
paddle/fluid/operators/distributed/parameter_recv.cc
paddle/fluid/operators/distributed/parameter_recv.cc
+3
-0
paddle/fluid/operators/distributed/parameter_send.cc
paddle/fluid/operators/distributed/parameter_send.cc
+1
-1
paddle/fluid/operators/distributed_ops/send_recv_util.h
paddle/fluid/operators/distributed_ops/send_recv_util.h
+0
-10
paddle/fluid/operators/split_selected_rows_op.h
paddle/fluid/operators/split_selected_rows_op.h
+9
-4
未找到文件。
paddle/fluid/operators/distributed/parameter_recv.cc
浏览文件 @
ea0df4e8
...
...
@@ -80,7 +80,9 @@ void ParameterRecv<T>::operator()(const RpcContext &rpc_ctx,
framework
::
Tensor
*
recv_tensor
=
recv_var
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
dev_ctx
=
paddle
::
platform
::
CPUDeviceContext
();
int64_t
recv_numel
=
0
;
for
(
auto
*
in
:
recved_tensors
)
{
recv_numel
+=
in
->
numel
();
auto
in_stride
=
framework
::
stride_numel
(
in
->
dims
());
auto
out_stride
=
framework
::
stride_numel
(
recv_tensor
->
dims
());
StridedNumelCopyWithAxis
<
T
>
(
...
...
@@ -88,6 +90,7 @@ void ParameterRecv<T>::operator()(const RpcContext &rpc_ctx,
in
->
data
<
T
>
(),
in_stride
,
in_stride
[
0
]);
output_offset
+=
in_stride
[
0
];
}
PADDLE_ENFORCE_EQ
(
recv_numel
,
recv_tensor
->
numel
());
}
delete
local_scope
;
...
...
paddle/fluid/operators/distributed/parameter_send.cc
浏览文件 @
ea0df4e8
...
...
@@ -99,7 +99,7 @@ void ParameterSend<T>::operator()(const RpcContext &rpc_ctx,
// split rows index into output sparse vars
for
(
size_t
i
=
0
;
i
<
send_rows
.
size
();
++
i
)
{
int
out_idx
=
FindOutId
x
(
send_rows
[
i
],
abs_sections
);
int
out_idx
=
GetSectionInde
x
(
send_rows
[
i
],
abs_sections
);
outs_rows_idx
[
out_idx
].
push_back
(
send_rows
[
i
]);
outs_dense_idx
[
out_idx
].
push_back
(
i
);
}
...
...
paddle/fluid/operators/distributed_ops/send_recv_util.h
浏览文件 @
ea0df4e8
...
...
@@ -48,16 +48,6 @@ inline bool NeedSend(const framework::Scope& scope,
return
false
;
}
inline
int
FindOutIdx
(
int
row
,
const
std
::
vector
<
int64_t
>&
abs_sections
)
{
for
(
size_t
i
=
1
;
i
<
abs_sections
.
size
();
++
i
)
{
if
(
row
<
abs_sections
[
i
])
{
return
i
-
1
;
}
}
PADDLE_ENFORCE_LT
(
row
,
abs_sections
.
back
(),
"row should be less then max id"
);
return
abs_sections
.
size
()
-
1
;
}
inline
std
::
vector
<
int64_t
>
ToAbsoluteSection
(
const
std
::
vector
<
int64_t
>&
height_sections
)
{
std
::
vector
<
int64_t
>
abs_sections
;
...
...
paddle/fluid/operators/split_selected_rows_op.h
浏览文件 @
ea0df4e8
...
...
@@ -32,7 +32,8 @@ class SplitSelectedRowsOpKernel : public framework::OpKernel<T> {
auto
abs_sections
=
ToAbsoluteSection
(
height_sections
);
auto
x_rows
=
x
->
rows
();
auto
&
x_rows
=
x
->
rows
();
auto
height
=
x
->
height
();
std
::
vector
<
std
::
vector
<
int
>>
outs_rows_idx
;
std
::
vector
<
std
::
vector
<
int
>>
outs_dense_idx
;
...
...
@@ -44,8 +45,10 @@ class SplitSelectedRowsOpKernel : public framework::OpKernel<T> {
// split rows index into output sparse vars
for
(
size_t
i
=
0
;
i
<
x_rows
.
size
();
++
i
)
{
int
out_idx
=
FindOutIdx
(
x_rows
[
i
],
abs_sections
);
outs_rows_idx
[
out_idx
].
push_back
(
x_rows
[
i
]);
auto
&
id
=
x_rows
[
i
];
PADDLE_ENFORCE_LT
(
id
,
height
);
int
out_idx
=
GetSectionIndex
(
id
,
abs_sections
);
outs_rows_idx
[
out_idx
].
push_back
(
id
);
outs_dense_idx
[
out_idx
].
push_back
(
i
);
}
auto
place
=
ctx
.
GetPlace
();
...
...
@@ -59,7 +62,9 @@ class SplitSelectedRowsOpKernel : public framework::OpKernel<T> {
outs
[
i
]
->
mutable_rows
()
->
clear
();
if
(
rows_idx
.
size
()
>
0
)
{
for
(
auto
idx
:
rows_idx
)
{
outs
[
i
]
->
mutable_rows
()
->
push_back
(
idx
-
abs_sections
[
i
]);
auto
id_offset
=
idx
-
abs_sections
[
i
];
PADDLE_ENFORCE_LT
(
id_offset
,
height_sections
[
i
]);
outs
[
i
]
->
mutable_rows
()
->
push_back
(
id_offset
);
}
auto
dst
=
outs
[
i
]
->
mutable_value
()
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
for
(
size_t
j
=
0
;
j
<
rows_idx
.
size
();
j
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录