Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a14ae84b
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看板
未验证
提交
a14ae84b
编写于
12月 08, 2022
作者:
H
HongyuJia
提交者:
GitHub
12月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt kernel_selection error msg (#48864)
上级
52116b16
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
12 addition
and
26 deletion
+12
-26
paddle/phi/core/kernel_factory.cc
paddle/phi/core/kernel_factory.cc
+12
-26
未找到文件。
paddle/phi/core/kernel_factory.cc
浏览文件 @
a14ae84b
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "paddle/phi/core/compat/convert_utils.h"
#include "paddle/phi/core/compat/convert_utils.h"
#endif
#endif
#include "paddle/phi/core/compat/op_utils.h"
#include "paddle/phi/core/compat/op_utils.h"
#include "paddle/utils/string/string_helper.h"
DECLARE_bool
(
enable_api_kernel_fallback
);
DECLARE_bool
(
enable_api_kernel_fallback
);
...
@@ -28,7 +29,7 @@ namespace phi {
...
@@ -28,7 +29,7 @@ namespace phi {
const
static
Kernel
empty_kernel
;
// NOLINT
const
static
Kernel
empty_kernel
;
// NOLINT
std
::
string
kernel_selection_error_m
essage
(
const
std
::
string
&
kernel_name
,
std
::
string
KernelSelectionErrorM
essage
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
target_key
);
const
KernelKey
&
target_key
);
uint32_t
KernelKey
::
Hash
::
operator
()(
const
KernelKey
&
key
)
const
{
uint32_t
KernelKey
::
Hash
::
operator
()(
const
KernelKey
&
key
)
const
{
...
@@ -146,7 +147,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
...
@@ -146,7 +147,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
"The kernel with key %s of kernel `%s` is not registered. %s"
,
"The kernel with key %s of kernel `%s` is not registered. %s"
,
kernel_key
,
kernel_key
,
kernel_name
,
kernel_name
,
kernel_selection_error_m
essage
(
kernel_name
,
kernel_key
)));
KernelSelectionErrorM
essage
(
kernel_name
,
kernel_key
)));
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
VLOG
(
6
)
<<
"fluid_op_name: "
<<
TransToFluidOpName
(
kernel_name
);
VLOG
(
6
)
<<
"fluid_op_name: "
<<
TransToFluidOpName
(
kernel_name
);
...
@@ -176,7 +177,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
...
@@ -176,7 +177,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
"fail to fallback to CPU one. %s"
,
"fail to fallback to CPU one. %s"
,
kernel_key
,
kernel_key
,
kernel_name
,
kernel_name
,
kernel_selection_error_m
essage
(
kernel_name
,
kernel_key
)));
KernelSelectionErrorM
essage
(
kernel_name
,
kernel_key
)));
VLOG
(
3
)
<<
"missing "
<<
kernel_key
.
backend
()
<<
" kernel: "
<<
kernel_name
VLOG
(
3
)
<<
"missing "
<<
kernel_key
.
backend
()
<<
" kernel: "
<<
kernel_name
<<
", expected_kernel_key:"
<<
kernel_key
<<
", expected_kernel_key:"
<<
kernel_key
...
@@ -195,7 +196,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
...
@@ -195,7 +196,7 @@ KernelResult KernelFactory::SelectKernelOrThrowError(
" to CPU one, please set the flag true before run again."
,
" to CPU one, please set the flag true before run again."
,
kernel_key
,
kernel_key
,
kernel_name
,
kernel_name
,
kernel_selection_error_m
essage
(
kernel_name
,
kernel_key
)));
KernelSelectionErrorM
essage
(
kernel_name
,
kernel_key
)));
return
{
kernel_iter
->
second
,
false
};
return
{
kernel_iter
->
second
,
false
};
}
}
...
@@ -368,7 +369,7 @@ std::ostream& operator<<(std::ostream& os, KernelFactory& kernel_factory) {
...
@@ -368,7 +369,7 @@ std::ostream& operator<<(std::ostream& os, KernelFactory& kernel_factory) {
// (GPU, Undefined(AnyLayout), [float32, float64, ...]);
// (GPU, Undefined(AnyLayout), [float32, float64, ...]);
// ...
// ...
// }
// }
std
::
string
kernel_selection_error_m
essage
(
const
std
::
string
&
kernel_name
,
std
::
string
KernelSelectionErrorM
essage
(
const
std
::
string
&
kernel_name
,
const
KernelKey
&
target_key
)
{
const
KernelKey
&
target_key
)
{
PADDLE_ENFORCE_NE
(
PADDLE_ENFORCE_NE
(
KernelFactory
::
Instance
().
kernels
().
find
(
kernel_name
),
KernelFactory
::
Instance
().
kernels
().
find
(
kernel_name
),
...
@@ -402,12 +403,7 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
...
@@ -402,12 +403,7 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
// 1. If target_key not supports target backend, output "Selected wrong
// 1. If target_key not supports target backend, output "Selected wrong
// Backend ..."
// Backend ..."
if
(
!
support_backend
)
{
if
(
!
support_backend
)
{
std
::
string
error_message
=
""
;
std
::
string
error_message
=
paddle
::
string
::
join_strings
(
backend_set
,
", "
);
for
(
auto
iter
=
backend_set
.
begin
();
iter
!=
backend_set
.
end
();
++
iter
)
{
error_message
+=
*
iter
;
error_message
+=
", "
;
}
error_message
=
error_message
.
substr
(
0
,
error_message
.
length
()
-
2
);
return
"Selected wrong Backend `"
+
return
"Selected wrong Backend `"
+
paddle
::
experimental
::
BackendToString
(
target_key
.
backend
())
+
paddle
::
experimental
::
BackendToString
(
target_key
.
backend
())
+
"`. Paddle support following Backends: "
+
error_message
+
"."
;
"`. Paddle support following Backends: "
+
error_message
+
"."
;
...
@@ -415,12 +411,7 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
...
@@ -415,12 +411,7 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
// 2. If target_key not supports target datatype, output "Selected wrong
// 2. If target_key not supports target datatype, output "Selected wrong
// DataType ..."
// DataType ..."
if
(
!
support_dtype
)
{
if
(
!
support_dtype
)
{
std
::
string
error_message
=
""
;
std
::
string
error_message
=
paddle
::
string
::
join_strings
(
dtype_set
,
", "
);
for
(
auto
iter
=
dtype_set
.
begin
();
iter
!=
dtype_set
.
end
();
++
iter
)
{
error_message
+=
*
iter
;
error_message
+=
", "
;
}
error_message
=
error_message
.
substr
(
0
,
error_message
.
length
()
-
2
);
return
"Selected wrong DataType `"
+
return
"Selected wrong DataType `"
+
paddle
::
experimental
::
DataTypeToString
(
target_key
.
dtype
())
+
paddle
::
experimental
::
DataTypeToString
(
target_key
.
dtype
())
+
"`. Paddle support following DataTypes: "
+
error_message
+
"."
;
"`. Paddle support following DataTypes: "
+
error_message
+
"."
;
...
@@ -431,14 +422,9 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
...
@@ -431,14 +422,9 @@ std::string kernel_selection_error_message(const std::string& kernel_name,
kernel_name
+
"`: { "
;
kernel_name
+
"`: { "
;
for
(
auto
iter
=
all_kernel_key
.
begin
();
iter
!=
all_kernel_key
.
end
();
for
(
auto
iter
=
all_kernel_key
.
begin
();
iter
!=
all_kernel_key
.
end
();
++
iter
)
{
++
iter
)
{
message
+=
"("
+
iter
->
first
+
", ["
;
std
::
vector
<
std
::
string
>&
dtype_vec
=
iter
->
second
;
std
::
vector
<
std
::
string
>&
dtype_vec
=
iter
->
second
;
for
(
std
::
size_t
i
=
0
;
i
<
dtype_vec
.
size
();
++
i
)
{
message
+=
"("
+
iter
->
first
+
", ["
;
message
+=
dtype_vec
[
i
];
message
+=
paddle
::
string
::
join_strings
(
dtype_vec
,
", "
);
if
(
i
+
1
!=
dtype_vec
.
size
())
{
message
+=
", "
;
}
}
message
+=
"]); "
;
message
+=
"]); "
;
}
}
message
+=
"}."
;
message
+=
"}."
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录