Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
0c24b3f9
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看板
提交
0c24b3f9
编写于
4月 25, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean memcpy async
上级
bfbbe19f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
8 addition
and
33 deletion
+8
-33
paddle/fluid/framework/details/fetch_op_handle.cc
paddle/fluid/framework/details/fetch_op_handle.cc
+0
-1
paddle/fluid/pybind/tensor_py.h
paddle/fluid/pybind/tensor_py.h
+8
-32
未找到文件。
paddle/fluid/framework/details/fetch_op_handle.cc
浏览文件 @
0c24b3f9
...
@@ -67,7 +67,6 @@ void FetchOpHandle::RunImpl() {
...
@@ -67,7 +67,6 @@ void FetchOpHandle::RunImpl() {
if
(
platform
::
is_gpu_place
(
t
.
place
()))
{
if
(
platform
::
is_gpu_place
(
t
.
place
()))
{
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
TensorCopy
(
t
,
cpu
,
*
dev_ctxes_
[
t
.
place
()],
&
tensors_
[
i
],
true
);
TensorCopy
(
t
,
cpu
,
*
dev_ctxes_
[
t
.
place
()],
&
tensors_
[
i
],
true
);
dev_ctxes_
.
at
(
t
.
place
())
->
Wait
();
#endif
#endif
}
else
{
}
else
{
tensors_
[
i
].
ShareDataWith
(
t
);
tensors_
[
i
].
ShareDataWith
(
t
);
...
...
paddle/fluid/pybind/tensor_py.h
浏览文件 @
0c24b3f9
...
@@ -63,15 +63,9 @@ struct CastToPyBufferImpl<true, I, ARGS...> {
...
@@ -63,15 +63,9 @@ struct CastToPyBufferImpl<true, I, ARGS...> {
auto
*
dst_ptr
=
static_cast
<
void
*>
(
dst_tensor
.
mutable_data
<
CUR_TYPE
>
(
auto
*
dst_ptr
=
static_cast
<
void
*>
(
dst_tensor
.
mutable_data
<
CUR_TYPE
>
(
tensor
.
dims
(),
platform
::
CPUPlace
()));
tensor
.
dims
(),
platform
::
CPUPlace
()));
platform
::
DeviceContextPool
&
pool
=
paddle
::
platform
::
GpuMemcpySync
(
dst_ptr
,
src_ptr
,
platform
::
DeviceContextPool
::
Instance
();
sizeof
(
CUR_TYPE
)
*
tensor
.
numel
(),
auto
dev_ctx
=
static_cast
<
const
platform
::
CUDADeviceContext
*>
(
cudaMemcpyDeviceToHost
);
pool
.
Get
(
tensor
.
place
()));
paddle
::
platform
::
GpuMemcpyAsync
(
dst_ptr
,
src_ptr
,
sizeof
(
CUR_TYPE
)
*
tensor
.
numel
(),
cudaMemcpyDeviceToHost
,
dev_ctx
->
stream
());
dev_ctx
->
Wait
();
#else
#else
PADDLE_THROW
(
"'CUDAPlace' is not supported in CPU only device."
);
PADDLE_THROW
(
"'CUDAPlace' is not supported in CPU only device."
);
#endif
#endif
...
@@ -184,17 +178,8 @@ void PyCUDATensorSetFromArray(
...
@@ -184,17 +178,8 @@ void PyCUDATensorSetFromArray(
self
->
Resize
(
framework
::
make_ddim
(
dims
));
self
->
Resize
(
framework
::
make_ddim
(
dims
));
auto
*
dst
=
self
->
mutable_data
<
T
>
(
place
);
auto
*
dst
=
self
->
mutable_data
<
T
>
(
place
);
paddle
::
platform
::
GpuMemcpySync
(
dst
,
array
.
data
(),
sizeof
(
T
)
*
array
.
size
(),
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
cudaMemcpyHostToDevice
);
auto
dev_ctx
=
static_cast
<
const
platform
::
CUDADeviceContext
*>
(
pool
.
Get
(
place
));
paddle
::
platform
::
GpuMemcpyAsync
(
dst
,
array
.
data
(),
sizeof
(
T
)
*
array
.
size
(),
cudaMemcpyHostToDevice
,
dev_ctx
->
stream
());
// NOTE: For safety, here wait the copy complete.
// It because the CPU array.data() could be destroyed after this method.
// If we make this method async, it could be copied data from a memory buffer
// that has been freed.
dev_ctx
->
Wait
();
}
}
template
<
>
template
<
>
...
@@ -214,18 +199,9 @@ void PyCUDATensorSetFromArray(
...
@@ -214,18 +199,9 @@ void PyCUDATensorSetFromArray(
self
->
Resize
(
framework
::
make_ddim
(
dims
));
self
->
Resize
(
framework
::
make_ddim
(
dims
));
auto
*
dst
=
self
->
mutable_data
<
platform
::
float16
>
(
place
);
auto
*
dst
=
self
->
mutable_data
<
platform
::
float16
>
(
place
);
paddle
::
platform
::
GpuMemcpySync
(
dst
,
array
.
data
(),
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
dev_ctx
=
static_cast
<
const
platform
::
CUDADeviceContext
*>
(
pool
.
Get
(
place
));
paddle
::
platform
::
GpuMemcpyAsync
(
dst
,
array
.
data
(),
sizeof
(
uint16_t
)
*
array
.
size
(),
sizeof
(
uint16_t
)
*
array
.
size
(),
cudaMemcpyHostToDevice
,
dev_ctx
->
stream
());
cudaMemcpyHostToDevice
);
// NOTE: For safety, here wait the copy complete.
// It because the CPU array.data() could be destroyed after this method.
// If we make this method async, it could be copied data from a memory buffer
// that has been freed.
dev_ctx
->
Wait
();
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录