未验证 提交 d79d5933 编写于 作者: D duanyanhui 提交者: GitHub

[Custom Device] Add static custom back_list (#50666)

* add static custom back_list

* rm comments

* fix log

* fix comment
上级 1882a74f
......@@ -759,12 +759,22 @@ bool BuildOpFuncList(const platform::Place& place,
op_with_kernel->Type())) {
auto phi_kernel_key = op_with_kernel->ChoosePhiKernel(exec_ctx);
auto phi_kernel_name = op_with_kernel->PhiKernelSignature()->name;
if (op_with_kernel->PhiKernel()->IsValid()) {
bool in_custom_back_list = false;
#ifdef PADDLE_WITH_CUSTOM_DEVICE
in_custom_back_list =
phi::backends::custom_device::is_in_custom_black_list(
phi_kernel_name);
#endif
if (op_with_kernel->PhiKernel()->IsValid() && !in_custom_back_list) {
run_phi_kernel = true;
} else {
if (!op_with_kernel->SupportsKernelType(expected_kernel_key,
exec_ctx)) {
if ((!op_with_kernel->SupportsKernelType(expected_kernel_key,
exec_ctx)) ||
in_custom_back_list) {
std::string info = in_custom_back_list ? "fluid in black list "
: "fluid missing ";
VLOG(3) << info << phi_kernel_key
<< " kernel: " << phi_kernel_name;
auto phi_cpu_kernel_key =
FallBackToCpu(phi_kernel_key, *op_with_kernel);
op_with_kernel->ResetPhiKernel(
......
......@@ -1888,7 +1888,12 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
bool is_xpu_kp_support = (use_xpu_kp_kernel_rt || use_xpu_kp_kernel_debug);
#endif
if (phi_kernel_->IsValid()
bool in_custom_back_list = false;
#if defined(PADDLE_WITH_CUSTOM_DEVICE)
in_custom_back_list =
phi::backends::custom_device::is_in_custom_black_list(phi_kernel_name);
#endif
if (phi_kernel_->IsValid() && !in_custom_back_list
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
&& !is_xpu_unsupport
#endif
......@@ -1909,7 +1914,6 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
kernel_type_->library_type_ = LibraryType::kKP;
}
#endif
if (kernels_iter == all_op_kernels.end() ||
kernels_iter->second.find(*kernel_type_.get()) ==
kernels_iter->second.end()
......@@ -1918,9 +1922,15 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
#endif
#if defined(PADDLE_WITH_XPU_KP)
|| (is_xpu_unsupport && !is_xpu_kp_support)
#endif
#if defined(PADDLE_WITH_CUSTOM_DEVICE)
|| in_custom_back_list
#endif
) {
fallback_to_cpu = true;
if (in_custom_back_list) {
VLOG(3) << "fluid in black list: " << phi_kernel_name;
}
auto phi_cpu_kernel_key = FallBackToCpu(phi_kernel_key, *this);
phi_kernel_.reset(
new phi::Kernel(phi::KernelFactory::Instance().SelectKernel(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册