Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
179b7893
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
179b7893
编写于
2月 06, 2018
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"fix CopyToPeer"
上级
709c157a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
5 deletion
+26
-5
paddle/framework/lod_tensor.h
paddle/framework/lod_tensor.h
+1
-1
paddle/framework/mixed_vector.h
paddle/framework/mixed_vector.h
+23
-2
paddle/operators/parallel_do_op.cc
paddle/operators/parallel_do_op.cc
+2
-2
未找到文件。
paddle/framework/lod_tensor.h
浏览文件 @
179b7893
...
@@ -65,7 +65,7 @@ struct LoD : public std::vector<Vector<size_t>> {
...
@@ -65,7 +65,7 @@ struct LoD : public std::vector<Vector<size_t>> {
void
CopyToPeer
(
platform
::
Place
place
)
{
void
CopyToPeer
(
platform
::
Place
place
)
{
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
{
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
{
it
->
mutable_data
(
place
);
it
->
CopyToPeer
(
place
);
}
}
}
}
};
};
...
...
paddle/framework/mixed_vector.h
浏览文件 @
179b7893
...
@@ -82,7 +82,7 @@ inline const T *Vector<T>::data(platform::Place place) const {
...
@@ -82,7 +82,7 @@ inline const T *Vector<T>::data(platform::Place place) const {
if
(
cuda_ptr_
==
nullptr
)
{
if
(
cuda_ptr_
==
nullptr
)
{
return
nullptr
;
return
nullptr
;
}
}
if
(
platform
::
is_same_place
(
place
,
place_
)
)
{
if
(
boost
::
get
<
platform
::
CUDAPlace
>
(
place
)
==
place_
)
{
return
static_cast
<
const
T
*>
(
cuda_ptr_
.
get
());
return
static_cast
<
const
T
*>
(
cuda_ptr_
.
get
());
}
else
{
}
else
{
PADDLE_THROW
(
PADDLE_THROW
(
...
@@ -99,7 +99,7 @@ inline T *Vector<T>::mutable_data(platform::Place place) {
...
@@ -99,7 +99,7 @@ inline T *Vector<T>::mutable_data(platform::Place place) {
if
(
platform
::
is_cpu_place
(
place
))
{
if
(
platform
::
is_cpu_place
(
place
))
{
return
std
::
vector
<
T
>::
data
();
return
std
::
vector
<
T
>::
data
();
}
else
if
(
platform
::
is_gpu_place
(
place
))
{
}
else
if
(
platform
::
is_gpu_place
(
place
))
{
if
(
!
platform
::
is_same_place
(
place
,
place_
)
)
{
if
(
boost
::
get
<
platform
::
CUDAPlace
>
(
place
)
!=
place_
)
{
place_
=
boost
::
get
<
platform
::
CUDAPlace
>
(
place
);
place_
=
boost
::
get
<
platform
::
CUDAPlace
>
(
place
);
}
}
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
...
@@ -159,5 +159,26 @@ void Vector<T>::CopyFromCUDA() {
...
@@ -159,5 +159,26 @@ void Vector<T>::CopyFromCUDA() {
#endif
#endif
}
}
template
<
typename
T
>
void
Vector
<
T
>::
CopyToPeer
(
platform
::
Place
place
)
{
#ifdef PADDLE_WITH_CUDA
if
(
boost
::
get
<
platform
::
CUDAPlace
>
(
place
)
!=
place_
)
{
place_
=
boost
::
get
<
platform
::
CUDAPlace
>
(
place
);
}
if
(
cuda_size_
<
this
->
size
()
||
cuda_ptr_
==
nullptr
)
{
cuda_ptr_
.
reset
(
memory
::
Alloc
<
platform
::
CUDAPlace
>
(
place_
,
this
->
size
()
*
sizeof
(
T
)),
memory
::
PlainDeleter
<
void
,
platform
::
CUDAPlace
>
(
place_
));
}
cuda_size_
=
this
->
size
();
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
*
ctx
=
pool
.
GetByPlace
(
place_
);
memory
::
Copy
(
place_
,
cuda_ptr_
.
get
(),
platform
::
CPUPlace
(),
static_cast
<
const
void
*>
(
this
->
data
()),
this
->
size
()
*
sizeof
(
T
),
ctx
->
stream
());
ctx
->
Wait
();
#endif
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
paddle/operators/parallel_do_op.cc
浏览文件 @
179b7893
...
@@ -79,7 +79,7 @@ inline void CopyOrShare(const framework::Variable &src,
...
@@ -79,7 +79,7 @@ inline void CopyOrShare(const framework::Variable &src,
dst
->
GetMutable
<
LoDTensor
>
()
->
set_lod
(
src
.
Get
<
LoDTensor
>
().
lod
());
dst
->
GetMutable
<
LoDTensor
>
()
->
set_lod
(
src
.
Get
<
LoDTensor
>
().
lod
());
}
else
{
}
else
{
Copy
(
src
.
Get
<
LoDTensor
>
(),
dst_place
,
dst
->
GetMutable
<
LoDTensor
>
());
Copy
(
src
.
Get
<
LoDTensor
>
(),
dst_place
,
dst
->
GetMutable
<
LoDTensor
>
());
LoD
lod
(
src
.
Get
<
LoDTensor
>
().
lod
());
framework
::
LoD
lod
(
src
.
Get
<
LoDTensor
>
().
lod
());
lod
.
CopyToPeer
(
dst_place
);
lod
.
CopyToPeer
(
dst_place
);
dst
->
GetMutable
<
LoDTensor
>
()
->
set_lod
(
lod
);
dst
->
GetMutable
<
LoDTensor
>
()
->
set_lod
(
lod
);
}
}
...
@@ -92,7 +92,7 @@ inline void CopyOrShare(const framework::Variable &src,
...
@@ -92,7 +92,7 @@ inline void CopyOrShare(const framework::Variable &src,
dst_sr
->
set_rows
(
src_sr
.
rows
());
dst_sr
->
set_rows
(
src_sr
.
rows
());
}
else
{
}
else
{
Copy
(
src_sr
.
value
(),
dst_place
,
dst_sr
->
mutable_value
());
Copy
(
src_sr
.
value
(),
dst_place
,
dst_sr
->
mutable_value
());
LoD
lod
(
src
.
Get
<
LoDTensor
>
().
lod
());
framework
::
Vector
<
int64_t
>
lod
(
src_sr
.
rows
());
lod
.
CopyToPeer
(
dst_place
);
lod
.
CopyToPeer
(
dst_place
);
dst_sr
->
set_rows
(
lod
);
dst_sr
->
set_rows
(
lod
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录