Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
660f3e25
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
660f3e25
编写于
2月 09, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix CI
上级
12246a9d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
17 addition
and
8 deletion
+17
-8
paddle/framework/mixed_vector.h
paddle/framework/mixed_vector.h
+10
-5
paddle/framework/mixed_vector_test.cu
paddle/framework/mixed_vector_test.cu
+4
-2
paddle/operators/math/selected_rows_functor.cu
paddle/operators/math/selected_rows_functor.cu
+3
-1
未找到文件。
paddle/framework/mixed_vector.h
浏览文件 @
660f3e25
...
@@ -277,12 +277,16 @@ class Vector {
...
@@ -277,12 +277,16 @@ class Vector {
kDirty
=
0x10
kDirty
=
0x10
};
};
void
MutableCPU
()
{
void
CopyToCPU
()
const
{
if
(
IsInCUDA
()
&&
IsDirty
())
{
// COPY GPU Data To CPU
// COPY GPU Data To CPU
Copy
(
cuda_vec_
,
platform
::
CPUPlace
(),
&
cpu_vec_
);
Copy
(
cuda_vec_
,
platform
::
CPUPlace
(),
&
cpu_vec_
);
WaitPlace
(
cuda_vec_
.
place
());
WaitPlace
(
cuda_vec_
.
place
());
}
}
void
MutableCPU
()
{
if
(
IsInCUDA
()
&&
IsDirty
())
{
CopyToCPU
();
}
flag_
=
kDirty
|
kDataInCPU
;
flag_
=
kDirty
|
kDataInCPU
;
}
}
...
@@ -311,8 +315,10 @@ class Vector {
...
@@ -311,8 +315,10 @@ class Vector {
SetFlag
(
kDataInCUDA
);
SetFlag
(
kDataInCUDA
);
}
else
if
(
!
(
place
==
cuda_vec_
.
place
()))
{
}
else
if
(
!
(
place
==
cuda_vec_
.
place
()))
{
framework
::
Tensor
tmp
;
framework
::
Tensor
tmp
;
WaitPlace
(
cuda_vec_
.
place
());
Copy
(
cuda_vec_
,
boost
::
get
<
platform
::
CUDAPlace
>
(
place
),
&
tmp
);
Copy
(
cuda_vec_
,
boost
::
get
<
platform
::
CUDAPlace
>
(
place
),
&
tmp
);
WaitPlace
(
cuda_vec_
.
place
());
WaitPlace
(
cuda_vec_
.
place
());
WaitPlace
(
place
);
cuda_vec_
.
ShareDataWith
(
tmp
);
cuda_vec_
.
ShareDataWith
(
tmp
);
}
else
{
}
else
{
// Not Dirty && DataInCUDA && Device is same
// Not Dirty && DataInCUDA && Device is same
...
@@ -324,8 +330,7 @@ class Vector {
...
@@ -324,8 +330,7 @@ class Vector {
void
ImmutableCPU
()
const
{
void
ImmutableCPU
()
const
{
if
(
IsDirty
()
&&
if
(
IsDirty
()
&&
!
IsInCPU
())
{
// If data has been changed in CUDA, or CPU has no data.
!
IsInCPU
())
{
// If data has been changed in CUDA, or CPU has no data.
Copy
(
cuda_vec_
,
platform
::
CPUPlace
(),
&
cpu_vec_
);
CopyToCPU
();
WaitPlace
(
cuda_vec_
.
place
());
UnsetFlag
(
kDirty
);
UnsetFlag
(
kDirty
);
}
}
SetFlag
(
kDataInCPU
);
SetFlag
(
kDataInCPU
);
...
...
paddle/framework/mixed_vector_test.cu
浏览文件 @
660f3e25
...
@@ -81,10 +81,12 @@ TEST(mixed_vector, MultiGPU) {
...
@@ -81,10 +81,12 @@ TEST(mixed_vector, MultiGPU) {
}
}
ASSERT_EQ
(
tmp
.
size
(),
10
);
ASSERT_EQ
(
tmp
.
size
(),
10
);
paddle
::
platform
::
CUDAPlace
gpu0
(
0
);
paddle
::
platform
::
CUDAPlace
gpu0
(
0
);
paddle
::
platform
::
SetDeviceId
(
0
);
multiply_10
<<<
1
,
1
,
0
,
GetCUDAStream
(
gpu0
)
>>>
(
tmp
.
MutableData
(
gpu0
));
multiply_10
<<<
1
,
1
,
0
,
GetCUDAStream
(
gpu0
)
>>>
(
tmp
.
MutableData
(
gpu0
));
paddle
::
platform
::
CUDAPlace
gpu1
(
1
);
paddle
::
platform
::
CUDAPlace
gpu1
(
1
);
multiply_10
<<<
1
,
1
,
0
,
GetCUDAStream
(
gpu1
)
>>>
(
tmp
.
MutableData
(
gpu1
));
auto
*
gpu1_ptr
=
tmp
.
MutableData
(
gpu1
);
paddle
::
platform
::
SetDeviceId
(
1
);
multiply_10
<<<
1
,
1
,
0
,
GetCUDAStream
(
gpu1
)
>>>
(
gpu1_ptr
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
ASSERT_EQ
(
tmp
[
i
],
i
*
100
);
ASSERT_EQ
(
tmp
[
i
],
i
*
100
);
}
}
...
...
paddle/operators/math/selected_rows_functor.cu
浏览文件 @
660f3e25
...
@@ -154,7 +154,9 @@ struct SelectedRowsAddTo<platform::CUDADeviceContext, T> {
...
@@ -154,7 +154,9 @@ struct SelectedRowsAddTo<platform::CUDADeviceContext, T> {
auto
*
in2_value
=
input2
->
mutable_value
();
auto
*
in2_value
=
input2
->
mutable_value
();
// concat rows
// concat rows
if
(
in1_rows
.
size
())
{
in2_rows
.
Extend
(
in1_rows
.
begin
(),
in1_rows
.
end
());
in2_rows
.
Extend
(
in1_rows
.
begin
(),
in1_rows
.
end
());
}
auto
in1_place
=
input1
.
place
();
auto
in1_place
=
input1
.
place
();
PADDLE_ENFORCE
(
platform
::
is_gpu_place
(
in1_place
));
PADDLE_ENFORCE
(
platform
::
is_gpu_place
(
in1_place
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录