Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
705776ca
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
705776ca
编写于
4月 01, 2022
作者:
L
Liu-xiandong
提交者:
GitHub
4月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[KP] fix bug in activation xpu kp kernel (#41219)
* fix bug in activation xpu kp kernel * delete useless comment
上级
f0f2e2f9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
7 deletion
+45
-7
paddle/fluid/imperative/prepared_operator.cc
paddle/fluid/imperative/prepared_operator.cc
+27
-7
paddle/phi/core/kernel_factory.cc
paddle/phi/core/kernel_factory.cc
+15
-0
paddle/phi/core/kernel_factory.h
paddle/phi/core/kernel_factory.h
+3
-0
未找到文件。
paddle/fluid/imperative/prepared_operator.cc
浏览文件 @
705776ca
...
...
@@ -191,12 +191,23 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins,
bool
is_xpu_kp_support
=
(
use_xpu_kp_kernel_rt
||
use_xpu_kp_kernel_debug
);
if
(
is_xpu_kp_support
)
{
auto
expected_kernel_key_library_type
=
expected_kernel_key
.
library_type_
;
expected_kernel_key
.
library_type_
=
paddle
::
framework
::
LibraryType
::
kKP
;
VLOG
(
3
)
<<
"modif
y
XPU KP kernel: "
<<
op
.
Type
()
VLOG
(
3
)
<<
"modif
ing
XPU KP kernel: "
<<
op
.
Type
()
<<
", using_kernel_key:"
<<
expected_kernel_key
;
phi
::
KernelKey
try_pt_kernel_key
=
TransOpKernelTypeToPhiKernelKey
(
expected_kernel_key
);
if
(
!
phi
::
KernelFactory
::
Instance
().
IsSelectKernelValid
(
pt_kernel_name
,
try_pt_kernel_key
))
{
expected_kernel_key
.
library_type_
=
expected_kernel_key_library_type
;
VLOG
(
3
)
<<
"modify XPU KP kernel: "
<<
op
.
Type
()
<<
" is failed "
<<
expected_kernel_key
;
}
}
}
#endif
pt_kernel_key
=
TransOpKernelTypeToPhiKernelKey
(
expected_kernel_key
);
auto
pt_kernel
=
phi
::
KernelFactory
::
Instance
().
SelectKernel
(
pt_kernel_name
,
pt_kernel_key
);
...
...
@@ -227,6 +238,20 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins,
auto
&
all_op_kernels
=
op
.
AllOpKernels
();
auto
kernels_iter
=
all_op_kernels
.
find
(
op
.
Type
());
#ifdef PADDLE_WITH_XPU_KP
bool
use_xpu_kp_kernel_rt
=
paddle
::
platform
::
is_xpu_place
(
expected_kernel_key
.
place_
)
&&
FLAGS_run_kp_kernel
&&
paddle
::
platform
::
is_xpu_kp_support_op
(
op
.
Type
(),
expected_kernel_key
);
bool
use_xpu_kp_kernel_debug
=
paddle
::
platform
::
is_xpu_place
(
expected_kernel_key
.
place_
)
&&
paddle
::
platform
::
is_in_xpu_kpwhite_list
(
op
.
Type
());
bool
is_xpu_kp_support
=
(
use_xpu_kp_kernel_rt
||
use_xpu_kp_kernel_debug
);
if
(
is_xpu_kp_support
)
{
expected_kernel_key
.
library_type_
=
paddle
::
framework
::
LibraryType
::
kKP
;
}
#endif
if
((
kernels_iter
==
all_op_kernels
.
end
()
||
kernels_iter
->
second
.
find
(
expected_kernel_key
)
==
kernels_iter
->
second
.
end
())
...
...
@@ -255,6 +280,7 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins,
platform
::
errors
::
NotFound
(
"There are no kernels which are registered in the %s operator."
,
op
.
Type
()));
auto
&
kernels
=
kernels_iter
->
second
;
auto
kernel_iter
=
kernels
.
find
(
expected_kernel_key
);
...
...
@@ -271,18 +297,12 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins,
#ifdef PADDLE_WITH_XPU_KP
if
(
paddle
::
platform
::
is_xpu_place
(
expected_kernel_key
.
place_
))
{
bool
use_xpu_kp_kernel_rt
=
FLAGS_run_kp_kernel
&&
paddle
::
platform
::
is_xpu_kp_support_op
(
op
.
Type
(),
expected_kernel_key
);
bool
use_xpu_kp_kernel_debug
=
paddle
::
platform
::
is_in_xpu_kpwhite_list
(
op
.
Type
());
if
(
use_xpu_kp_kernel_rt
)
{
VLOG
(
3
)
<<
"xpu_kp using rt mode "
;
}
if
(
use_xpu_kp_kernel_debug
)
{
VLOG
(
3
)
<<
"xpu_kp using debug mode "
;
}
bool
is_xpu_kp_support
=
(
use_xpu_kp_kernel_rt
||
use_xpu_kp_kernel_debug
);
if
(
is_xpu_kp_support
)
{
expected_kernel_key
.
library_type_
=
paddle
::
framework
::
LibraryType
::
kKP
;
kernel_iter
=
kernels
.
find
(
expected_kernel_key
);
...
...
paddle/phi/core/kernel_factory.cc
浏览文件 @
705776ca
...
...
@@ -59,6 +59,21 @@ KernelKeyMap KernelFactory::SelectKernelMap(
return
iter
->
second
;
}
bool
KernelFactory
::
IsSelectKernelValid
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
kernel_key
)
const
{
auto
iter
=
kernels_
.
find
(
kernel_name
);
PADDLE_ENFORCE_NE
(
iter
,
kernels_
.
end
(),
phi
::
errors
::
NotFound
(
"The kernel `%s` is not registered."
,
kernel_name
));
auto
kernel_iter
=
iter
->
second
.
find
(
kernel_key
);
if
(
kernel_iter
==
iter
->
second
.
end
())
{
return
false
;
}
return
true
;
}
const
Kernel
&
KernelFactory
::
SelectKernelOrThrowError
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
kernel_key
)
const
{
auto
iter
=
kernels_
.
find
(
kernel_name
);
...
...
paddle/phi/core/kernel_factory.h
浏览文件 @
705776ca
...
...
@@ -245,6 +245,9 @@ class KernelFactory {
DataLayout
layout
,
DataType
dtype
)
const
;
bool
IsSelectKernelValid
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
kernel_key
)
const
;
Kernel
SelectKernel
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
kernel_key
)
const
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录