Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
60fc555e
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看板
未验证
提交
60fc555e
编写于
2月 22, 2022
作者:
R
ronnywang
提交者:
GitHub
2月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CustomRuntime] fix CustomDeviceContext (#39766)
上级
c5d15655
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
10 addition
and
28 deletion
+10
-28
paddle/fluid/platform/CMakeLists.txt
paddle/fluid/platform/CMakeLists.txt
+3
-1
paddle/fluid/platform/device_context.cc
paddle/fluid/platform/device_context.cc
+4
-12
paddle/fluid/platform/device_context.h
paddle/fluid/platform/device_context.h
+2
-12
paddle/phi/common/backend.h
paddle/phi/common/backend.h
+0
-3
paddle/phi/common/place.h
paddle/phi/common/place.h
+1
-0
未找到文件。
paddle/fluid/platform/CMakeLists.txt
浏览文件 @
60fc555e
...
...
@@ -141,7 +141,9 @@ if(WITH_GPU OR WITH_ROCM)
target_link_libraries
(
device_context gpu_info gpu_context pten_gpu_info
)
target_link_libraries
(
device_context gpu_resource_pool
)
endif
()
if
(
WITH_CUSTOM_DEVICE
)
target_link_libraries
(
device_context custom_context
)
endif
()
if
(
WITH_ASCEND_CL
)
target_link_libraries
(
device_context npu_resource_pool
)
endif
()
...
...
paddle/fluid/platform/device_context.cc
浏览文件 @
60fc555e
...
...
@@ -897,21 +897,13 @@ MKLDNNDeviceContext::BlobPtr_t<void> MKLDNNDeviceContext::GetBlob(
#endif
#ifdef PADDLE_WITH_CUSTOM_DEVICE
CustomDeviceContext
::
CustomDeviceContext
(
CustomPlace
place
)
:
place_
(
place
)
{
DeviceGuard
guard
(
place_
);
stream_
.
reset
(
new
stream
::
Stream
()
);
stream_
->
Init
(
place_
);
CustomDeviceContext
::
CustomDeviceContext
(
CustomPlace
place
)
:
phi
::
CustomContext
(
place
)
{
Init
(
);
stream_
.
reset
(
new
platform
::
stream
::
Stream
(
place
,
stream
())
);
}
CustomDeviceContext
::~
CustomDeviceContext
()
{}
const
Place
&
CustomDeviceContext
::
GetPlace
()
const
{
return
place_
;
}
void
CustomDeviceContext
::
Wait
()
const
{
// platform::RecordEvent record_event("NPUDeviceContext/wait");
VLOG
(
4
)
<<
"CustomDevice context("
<<
this
<<
") Wait"
;
stream_
->
Wait
();
}
#endif
}
// namespace platform
}
// namespace paddle
paddle/fluid/platform/device_context.h
浏览文件 @
60fc555e
...
...
@@ -21,6 +21,7 @@ limitations under the License. */
#include "paddle/fluid/platform/device/gpu/gpu_types.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/backends/custom/custom_context.h"
#include "paddle/phi/backends/gpu/gpu_decls.h"
#include "paddle/phi/core/device_context.h"
...
...
@@ -819,17 +820,12 @@ class MKLDNNDeviceContext : public CPUDeviceContext {
#endif
#ifdef PADDLE_WITH_CUSTOM_DEVICE
class
CustomDeviceContext
:
public
Device
Context
{
class
CustomDeviceContext
:
public
phi
::
Custom
Context
{
public:
explicit
CustomDeviceContext
(
CustomPlace
place
);
virtual
~
CustomDeviceContext
();
const
Place
&
GetPlace
()
const
override
;
void
Wait
()
const
override
;
Eigen
::
DefaultDevice
*
eigen_device
()
const
{
return
nullptr
;
}
C_Stream
stream
()
const
{
return
reinterpret_cast
<
C_Stream
>
(
stream_
->
raw_stream
());
}
template
<
typename
Callback
>
void
AddStreamCallback
(
Callback
&&
callback
)
const
{
...
...
@@ -839,13 +835,7 @@ class CustomDeviceContext : public DeviceContext {
void
WaitStreamCallback
()
const
{
return
stream_
->
WaitCallback
();
}
private:
std
::
string
device_type_
;
CustomPlace
place_
;
std
::
shared_ptr
<
platform
::
stream
::
Stream
>
stream_
;
CustomDeviceContext
();
};
template
<
>
struct
DefaultDeviceContextType
<
platform
::
CustomPlace
>
{
...
...
paddle/phi/common/backend.h
浏览文件 @
60fc555e
...
...
@@ -135,9 +135,6 @@ inline Backend StringToBackend(const char* backend_cstr) {
if
(
s
==
std
::
string
(
"Undefined"
))
{
return
Backend
::
UNDEFINED
;
}
for
(
size_t
i
=
0
;
i
<
s
.
size
();
++
i
)
{
s
[
i
]
=
toupper
(
s
[
i
]);
}
if
(
s
==
std
::
string
(
"CPU"
))
{
return
Backend
::
CPU
;
}
else
if
(
s
==
std
::
string
(
"GPU"
))
{
...
...
paddle/phi/common/place.h
浏览文件 @
60fc555e
...
...
@@ -188,6 +188,7 @@ class MLUPlace : public Place {
class
CustomPlace
:
public
Place
{
public:
CustomPlace
()
:
Place
(
AllocationType
::
CUSTOM
,
0
,
""
)
{}
explicit
CustomPlace
(
const
std
::
string
dev_type
)
:
Place
(
AllocationType
::
CUSTOM
,
0
,
dev_type
)
{}
CustomPlace
(
const
std
::
string
dev_type
,
int
device_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录