未验证 提交 f275bf6d 编写于 作者: L Liu-xiandong 提交者: GitHub

[cherry-pick 2.3]fix bug when TruncatedNormal cannot fall back in cpu (#41595)

fix bug when TruncatedNormal cannot fall back in cpu
上级 53aef69c
...@@ -1333,7 +1333,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, ...@@ -1333,7 +1333,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
// NOTE(Liu-xiandong): Determine whether the selected kernel is valid // NOTE(Liu-xiandong): Determine whether the selected kernel is valid
// If not, use the kernel registered in fluid. And if the fluid do not // If not, use the kernel registered in fluid. And if the fluid do not
// contains the related heterogeneous kernel, use phi CPU kernel. // contains the related heterogeneous kernel, use phi CPU kernel.
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP) #if defined(PADDLE_WITH_XPU)
bool is_xpu_unsupport = bool is_xpu_unsupport =
paddle::platform::is_xpu_place(kernel_type_->place_) && paddle::platform::is_xpu_place(kernel_type_->place_) &&
!paddle::platform::is_xpu_support_op(type_, *kernel_type_.get()) || !paddle::platform::is_xpu_support_op(type_, *kernel_type_.get()) ||
...@@ -1372,6 +1372,9 @@ void OperatorWithKernel::RunImpl(const Scope& scope, ...@@ -1372,6 +1372,9 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
kernels_iter->second.end() kernels_iter->second.end()
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP) #if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
|| is_xpu_unsupport || is_xpu_unsupport
#endif
#if defined(PADDLE_WITH_XPU_KP)
|| (is_xpu_unsupport && !is_xpu_kp_support)
#endif #endif
) { ) {
auto pt_cpu_kernel_key = auto pt_cpu_kernel_key =
......
...@@ -262,6 +262,9 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins, ...@@ -262,6 +262,9 @@ PreparedOp PrepareImpl(const NameVarMap<VarType>& ins,
kernels_iter->second.end()) kernels_iter->second.end())
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP) #if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
|| is_xpu_unsupport || is_xpu_unsupport
#endif
#if defined(PADDLE_WITH_XPU_KP)
|| (is_xpu_unsupport && !is_xpu_kp_support)
#endif #endif
) { ) {
if (phi::KernelFactory::Instance().HasCompatiblePhiKernel(op.Type())) { if (phi::KernelFactory::Instance().HasCompatiblePhiKernel(op.Type())) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册