Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
323566d5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
323566d5
编写于
8月 31, 2023
作者:
H
hong
提交者:
GitHub
8月 31, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NewIR]Fix install check bug (#56768)
* fix install check bug * fix bug
上级
6ae17635
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
43 addition
and
9 deletion
+43
-9
paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc
paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc
+43
-9
未找到文件。
paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc
浏览文件 @
323566d5
...
...
@@ -94,6 +94,28 @@ bool NeedFallBackCpu(const ir::Operation* op,
return
false
;
}
phi
::
Backend
GetDstBackend
(
const
std
::
string
&
op_name
,
phi
::
Place
place
,
OpYamlInfoParser
*
op_yaml_info_parser
,
phi
::
Backend
kernel_def_backend
,
size_t
input_index
)
{
if
(
op_name
==
"builtin.set_parameter"
&&
place
.
GetType
()
==
phi
::
AllocationType
::
GPU
)
{
// NOTE: align old executor, all the paramter are initilizered
// on backend of executor place defined
return
phi
::
TransToPhiBackend
(
place
);
}
auto
dst_backend
=
kernel_def_backend
;
if
(
op_yaml_info_parser
!=
nullptr
&&
op_yaml_info_parser
->
IsTensorAttribute
(
input_index
))
{
// Tensor Attribute should on cpu backend for better performance
dst_backend
=
phi
::
Backend
::
CPU
;
}
return
dst_backend
;
}
bool
NeedFallBackFromGPUDNN2GPU
(
ir
::
Operation
*
op
,
const
phi
::
KernelKey
kernel_key
)
{
// NOTE(phlrain): keep the same kernel select strategy with
...
...
@@ -182,6 +204,10 @@ ir::OpResult AddPlaceTransferOp(ir::OpResult in,
ir
::
Operation
*
op
=
ir
::
Operation
::
Create
({
in
},
op_attribute
,
{
out_type
},
op_info
);
if
(
in
.
GetDefiningOp
()
->
HasAttribute
(
kAttrIsPersisable
))
{
op
->
set_attribute
(
kAttrIsPersisable
,
in
.
GetDefiningOp
()
->
attribute
(
kAttrIsPersisable
));
}
program
->
block
()
->
push_back
(
op
);
auto
new_in
=
op
->
result
(
0
);
...
...
@@ -844,10 +870,14 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog,
auto
&
kernel
=
phi
::
KernelFactory
::
Instance
().
SelectKernelWithGPUDNN
(
kernel_fn_str
,
kernel_key
);
if
(
kernel
.
IsValid
()
&&
(
!
UnchangeOutputOps
.
count
(
op_item
->
name
())))
{
bool
check_place_transfer
=
(
op_item
->
name
()
==
"builtin.set_parameter"
)
||
(
kernel
.
IsValid
()
&&
(
!
UnchangeOutputOps
.
count
(
op_item
->
name
())));
if
(
check_place_transfer
)
{
if
(
new_in_type
.
isa
<
dialect
::
AllocatedDenseTensorType
>
())
{
// allocated type
auto
place
=
auto
in_
place
=
new_in_type
.
dyn_cast
<
dialect
::
AllocatedDenseTensorType
>
()
.
place
();
...
...
@@ -855,17 +885,21 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog,
auto
args_def
=
kernel
.
args_def
();
auto
input_defs
=
args_def
.
input_defs
();
auto
dst_backend
=
GetDstBackend
(
op_item
->
name
(),
place
,
op_info_parser
.
get
(),
kernel
.
InputAt
(
i
).
backend
,
i
);
bool
need_trans
=
(
place
.
GetType
()
!=
phi
::
AllocationType
::
UNDEFINED
)
&&
(
op_info_parser
!=
nullptr
&&
!
op_info_parser
->
IsTensorAttribute
(
i
))
&&
(
in_place
.
GetType
()
!=
phi
::
AllocationType
::
UNDEFINED
)
&&
(
paddle
::
experimental
::
NeedTransformPlace
(
place
,
kernel
.
InputAt
(
i
).
backend
,
{}));
in_place
,
dst_
backend
,
{}));
if
(
need_trans
)
{
VLOG
(
6
)
<<
"need trans from "
<<
place
<<
" to "
VLOG
(
6
)
<<
"need trans from "
<<
in_
place
<<
" to "
<<
kernel_key
.
backend
();
// build memcopy op
auto
out_place
=
phi
::
TransToPhiPlace
(
kernel
.
InputAt
(
i
).
backend
);
auto
out_place
=
phi
::
TransToPhiPlace
(
dst_
backend
);
auto
new_in_alloc_type
=
new_in_type
.
dyn_cast
<
dialect
::
AllocatedDenseTensorType
>
();
auto
out_type
=
dialect
::
AllocatedDenseTensorType
::
get
(
...
...
@@ -878,7 +912,7 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog,
new_in_alloc_type
.
offset
());
new_in
=
AddPlaceTransferOp
(
new_in
,
out_type
,
place
,
in_
place
,
out_place
,
kernel_key
,
program
.
get
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录