Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
71305e5f
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
71305e5f
编写于
10月 29, 2017
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"polish code based on comment"
上级
6f009cf8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
13 addition
and
11 deletion
+13
-11
paddle/framework/operator.h
paddle/framework/operator.h
+2
-2
paddle/operators/nccl_op.cc
paddle/operators/nccl_op.cc
+5
-0
paddle/operators/nccl_op.cu
paddle/operators/nccl_op.cu
+2
-3
paddle/operators/nccl_op_test.cu
paddle/operators/nccl_op_test.cu
+4
-6
未找到文件。
paddle/framework/operator.h
浏览文件 @
71305e5f
...
...
@@ -290,12 +290,12 @@ class ExecutionContext {
return
device_context_
;
}
//! Get
variables vector with same input name
.
//! Get
actual name vector for this input
.
const
std
::
vector
<
std
::
string
>&
Inputs
(
const
std
::
string
&
name
)
const
{
return
op_
.
Inputs
(
name
);
}
//! Get
variables vector with same output name
.
//! Get
actual name vector for this output
.
const
std
::
vector
<
std
::
string
>&
Outputs
(
const
std
::
string
&
name
)
const
{
return
op_
.
Outputs
(
name
);
}
...
...
paddle/operators/nccl_op.cc
浏览文件 @
71305e5f
...
...
@@ -30,6 +30,11 @@ class NCCLInitOp : public framework::OperatorBase {
"Can not find variable '%s' in the scope."
,
name
);
std
::
vector
<
int
>
gpus
=
Attr
<
std
::
vector
<
int
>>
(
"gpus"
);
PADDLE_ENFORCE
(
!
gpus
.
empty
(),
"Attr(gpus) should not be empty."
);
if
(
scope
.
FindVar
(
name
)
==
nullptr
)
{
PADDLE_THROW
(
"Output(Communicator) is needed for ncclInit operator."
);
}
platform
::
Communicator
*
comm
=
scope
.
FindVar
(
name
)
->
GetMutable
<
platform
::
Communicator
>
();
comm
->
InitAll
(
gpus
);
...
...
paddle/operators/nccl_op.cu
浏览文件 @
71305e5f
...
...
@@ -9,7 +9,6 @@ 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. */
#define EIGEN_USE_GPU
#include <functional>
#include "paddle/framework/lod_tensor.h"
...
...
@@ -60,7 +59,7 @@ class NCCLAllReduceKernel : public framework::OpKernel<T> {
}
else
if
(
reduction
==
"ncclProd"
)
{
reduction_op_
=
ncclProd
;
}
else
{
PADDLE_
ENFORCE
(
false
,
"Invalid reduction. default ncclSum."
);
PADDLE_
THROW
(
"Invalid reduction. default ncclSum."
);
}
auto
*
comm
=
ctx
.
Input
<
Communicator
>
(
"Communicator"
);
...
...
@@ -113,7 +112,7 @@ class NCCLReduceKernel : public framework::OpKernel<T> {
}
else
if
(
reduction
==
"ncclProd"
)
{
reduction_op_
=
ncclProd
;
}
else
{
PADDLE_
ENFORCE
(
false
,
"Invalid reduction. default ncclSum."
);
PADDLE_
THROW
(
"Invalid reduction. default ncclSum."
);
}
int
root
=
ctx
.
Attr
<
int
>
(
"root"
);
...
...
paddle/operators/nccl_op_test.cu
浏览文件 @
71305e5f
...
...
@@ -12,8 +12,6 @@
See the License for the specific language governing permissions and
limitations under the License. */
#define EIGEN_USE_GPU
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <algorithm>
...
...
@@ -193,7 +191,7 @@ TEST_F(NCCLTester, ncclAllReduceOp) {
}
}
// nccl
A
ReduceOp with desc
// ncclReduceOp with desc
TEST_F
(
NCCLTester
,
ncclReduceOp
)
{
std
::
unique_ptr
<
f
::
OpDescBind
>
op2
(
new
f
::
OpDescBind
);
const
int
kRoot
=
0
;
...
...
@@ -201,7 +199,7 @@ TEST_F(NCCLTester, ncclReduceOp) {
op2
->
SetInput
(
"X"
,
{
"st"
});
op2
->
SetInput
(
"Communicator"
,
{
"comm"
});
op2
->
SetOutput
(
"Out"
,
{
"rt"
});
op2
->
SetAttr
(
"root"
,
{
kRoot
}
);
op2
->
SetAttr
(
"root"
,
kRoot
);
std
::
vector
<
f
::
Scope
*>
dev_scopes
;
...
...
@@ -241,7 +239,7 @@ TEST_F(NCCLTester, ncclReduceOp) {
}
}
//
//
ncclBcastOp with desc
// ncclBcastOp with desc
TEST_F
(
NCCLTester
,
ncclBcastOp
)
{
std
::
unique_ptr
<
f
::
OpDescBind
>
op2
(
new
f
::
OpDescBind
);
const
int
kRoot
=
5
;
...
...
@@ -249,7 +247,7 @@ TEST_F(NCCLTester, ncclBcastOp) {
op2
->
SetInput
(
"X"
,
{
"st"
});
op2
->
SetInput
(
"Communicator"
,
{
"comm"
});
op2
->
SetOutput
(
"Out"
,
{
"rt"
});
op2
->
SetAttr
(
"root"
,
{
kRoot
}
);
op2
->
SetAttr
(
"root"
,
kRoot
);
std
::
vector
<
f
::
Scope
*>
dev_scopes
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录