Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
a896b32b
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看板
未验证
提交
a896b32b
编写于
9月 13, 2022
作者:
L
Leo Chen
提交者:
GitHub
9月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set device id before op run (#45993)
上级
476470da
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
2 deletion
+48
-2
paddle/fluid/framework/new_executor/interpretercore.cc
paddle/fluid/framework/new_executor/interpretercore.cc
+48
-2
未找到文件。
paddle/fluid/framework/new_executor/interpretercore.cc
浏览文件 @
a896b32b
...
...
@@ -29,6 +29,7 @@
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
#include "paddle/phi/backends/device_manager.h"
PADDLE_DEFINE_EXPORTED_bool
(
new_executor_use_inplace
,
false
,
...
...
@@ -596,16 +597,61 @@ void InterpreterCore::BuildSkipShareLoDInfo() {
}
}
inline
void
SetDeviceId
(
const
platform
::
Place
&
place
)
{
// TODO(zhiqiu): reduce the cost
if
(
platform
::
is_gpu_place
(
place
))
{
#if !defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP)
PADDLE_THROW
(
platform
::
errors
::
Unavailable
(
"Cannot run operator on place %s, please recompile paddle or "
"reinstall Paddle with CUDA support."
,
place
));
#else
auto
dev_id
=
place
.
device
;
platform
::
SetDeviceId
(
dev_id
);
#endif
}
else
if
(
platform
::
is_xpu_place
(
place
))
{
#ifndef PADDLE_WITH_XPU
PADDLE_THROW
(
platform
::
errors
::
Unavailable
(
"Cannot run operator on place %s, please recompile paddle or "
"reinstall Paddle with XPU support."
,
place
));
#else
auto
dev_id
=
place
.
device
;
platform
::
SetXPUDeviceId
(
dev_id
);
#endif
}
else
if
(
platform
::
is_npu_place
(
place
))
{
#ifndef PADDLE_WITH_ASCEND_CL
PADDLE_THROW
(
platform
::
errors
::
Unavailable
(
"Cannot run operator on place %s, please recompile paddle or "
"reinstall Paddle with NPU support."
,
place
));
#else
auto
dev_id
=
place
.
device
;
platform
::
SetNPUDeviceId
(
dev_id
);
#endif
}
else
if
(
platform
::
is_custom_place
(
place
))
{
#ifndef PADDLE_WITH_CUSTOM_DEVICE
PADDLE_THROW
(
platform
::
errors
::
Unavailable
(
"Cannot run operator on place %s, please recompile paddle or "
"reinstall Paddle with CustomDevice support."
,
place
));
#else
phi
::
DeviceManager
::
SetDevice
(
place
);
#endif
}
}
void
InterpreterCore
::
RunInstruction
(
const
Instruction
&
instr_node
)
{
auto
*
op
=
instr_node
.
OpBase
();
auto
place
=
instr_node
.
DeviceContext
().
GetPlace
();
Scope
*
local_scope
=
create_local_scope_
?
var_scope_
.
GetMutableLocalScope
()
:
var_scope_
.
GetMutableScope
();
VLOG
(
4
)
<<
"Start run "
<<
place
<<
" "
<<
op
->
DebugStringEx
(
local_scope_
);
SetDeviceId
(
place
);
#ifdef PADDLE_WITH_ASCEND_CL
if
(
platform
::
is_npu_place
(
place
))
{
auto
dev_id
=
place
.
device
;
platform
::
SetNPUDeviceId
(
dev_id
);
// NOTE(wangxi): nan/inf cannot be detected on NPU by checking the variable
// values, but only through special `float_status` to checks whether
// the operation is overflow. More about `float_status`, see:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录