diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index a03d75e3fe79af53a6c4fb4b114ecf72a575e29f..32933ef66170d13d8da791d924d0c0438c93997d 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1328,8 +1328,10 @@ bool OperatorWithKernel::SupportsMKLDNN( auto has_phi_kernel = std::any_of(phi_kernels.begin(), phi_kernels.end(), - [](phi::KernelKeyMap::const_reference kern_pair) { - return kern_pair.first.backend() == phi::Backend::ONEDNN; + [data_type](phi::KernelKeyMap::const_reference kern_pair) { + return kern_pair.first.backend() == phi::Backend::ONEDNN && + kern_pair.first.dtype() == + framework::TransToPhiDataType(data_type); }); if (has_phi_kernel) { return true;