From a16afb9fbc494df456055db29369a71b5b3f9cc3 Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Sun, 4 Feb 2024 11:38:20 +0000 Subject: [PATCH 1/7] if cpu kernel not support bf16, select onednn kernel to run --- .../fluid/pir/dialect/op_generator/op_gen.py | 104 +++++++++++++++++- .../dialect/operator/interface/op_yaml_info.h | 3 + .../operator/utils/op_yaml_info_util.h | 4 + .../pir/transforms/pd_op_to_kernel_pass.cc | 82 ++++++++++++++ 4 files changed, 192 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/pir/dialect/op_generator/op_gen.py b/paddle/fluid/pir/dialect/op_generator/op_gen.py index a522a17f8cbf81..cdd31ec45ec430 100644 --- a/paddle/fluid/pir/dialect/op_generator/op_gen.py +++ b/paddle/fluid/pir/dialect/op_generator/op_gen.py @@ -260,7 +260,9 @@ class {TEST_API} {op_name} : public pir::Op<{op_name}{interfaces}{traits}> {{ std::vector inputs = {{ {inputs} }}; std::vector attributes = {{ {attributes} }}; std::vector outputs = {{ {outputs} }}; - paddle::dialect::OpRunTimeInfo run_time_info = paddle::dialect::OpRunTimeInfo("{infer_meta_func}", {{"{infer_meta_param}"}}, "{kernel_func}", {{"{kernel_param}"}}, {{{kernel_key_dtype}}}, {{{kernel_key_backend}}}, {{{inplace}}}, {{{view}}}, {{{extra_args}}}, {{{data_format_tensors}}}, {is_onednn_only}, {dynamic_fallback}); + pir::AttributeMap extra_attr_default_value; + {extra_attr_default_value_code} + paddle::dialect::OpRunTimeInfo run_time_info = paddle::dialect::OpRunTimeInfo("{infer_meta_func}", {{"{infer_meta_param}"}}, "{kernel_func}", {{"{kernel_param}"}}, {{{kernel_key_dtype}}}, {{{kernel_key_backend}}}, {{{inplace}}}, {{{view}}}, {{{extra_args}}}, extra_attr_default_value, {{{data_format_tensors}}}, {is_onednn_only}, {dynamic_fallback}); return std::make_tuple(inputs, attributes, outputs, run_time_info, "{origin_op_name}"); }} """ @@ -1126,6 +1128,94 @@ def get_mutable_attribute_grad_semantic(op_info, op_info_items): return mutable_attribute_grad_semantics +def GenOneDnnExtraAttrsDefaultValue(onednn_extra_args): + INTARRAY_STR_TEMPLATE = """ pir::Attribute attr_{attr_name} = {op_attribute_type}::get(pir::IrContext::Instance(), phi::IntArray({attr})); +""" + SCALAR_STR_TEMPLATE = """ pir::Attribute attr_{attr_name} = paddle::dialect::TransToIrAttribute({attr}, pir::IrContext::Instance()); +""" + STR_TEMPLATE = """ pir::Attribute attr_{attr_name} = {op_attribute_type}::get(pir::IrContext::Instance(), {attr}); +""" + ARRAY_ATTRIBUTE_TEMPLATE = """ std::vector vec_{attr_name}; +std::vector<{cpp_type}> vec_values = {attr_valuse}; +for (size_t i = 0; i < static_cast(vec_values.size()); i++) {{ + {create_attribute} + vec_{attr_name}.push_back(attr_{attr_name}); +}} +pir::Attribute attr_{attr_name} = pir::ArrayAttribute::get(pir::IrContext::Instance(), vec_{attr_name}); +""" + attr_str = "" + array_attr_type = "pir::ArrayAttribute<" + for idx in range(len(onednn_extra_args)): + assert ( + onednn_extra_args[idx]['typename'] in attr_types_map + ), f"{onednn_extra_args[idx]['typename']} : Attr type error." + extra_arg_type = attr_types_map[onednn_extra_args[idx]['typename']][0] + + if array_attr_type in extra_arg_type: + inner_attribute_type = extra_arg_type[len(array_attr_type) : -1] + if inner_attribute_type == "paddle::dialect::IntArrayAttribute": + attr_str += ARRAY_ATTRIBUTE_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + cpp_type=onednn_extra_args[idx]['typename'].replace( + '[]', '' + ), + attr_valuse=onednn_extra_args[idx]['default_value'], + create_attribute=INTARRAY_STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + op_attribute_type=inner_attribute_type, + attr="vec_values[i]", + ), + ) + elif inner_attribute_type == "paddle::dialect::ScalarAttribute": + attr_str += ARRAY_ATTRIBUTE_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + cpp_type=onednn_extra_args[idx]['typename'].replace( + '[]', '' + ), + attr_valuse=onednn_extra_args[idx]['default_value'], + create_attribute=SCALAR_STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + attr="vec_values[i]", + ), + ) + else: + attr_str += ARRAY_ATTRIBUTE_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + cpp_type=onednn_extra_args[idx]['typename'].replace( + '[]', '' + ), + attr_valuse=onednn_extra_args[idx]['default_value'], + create_attribute=STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + op_attribute_type=inner_attribute_type, + attr="vec_values[i]", + ), + ) + elif extra_arg_type == "paddle::dialect::IntArrayAttribute": + attr_str += INTARRAY_STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + op_attribute_type=extra_arg_type, + attr=onednn_extra_args[idx]['name'], + ) + elif extra_arg_type == "paddle::dialect::ScalarAttribute": + attr_str += SCALAR_STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + attr=onednn_extra_args[idx]['name'], + ) + else: + attr_str += STR_TEMPLATE.format( + attr_name=onednn_extra_args[idx]['name'], + op_attribute_type=extra_arg_type, + attr=onednn_extra_args[idx]['default_value'], + ) + + attr_str += """extra_attr_default_value["{attr_name}"] = attr_{attr_name};\n""".format( + attr_name=onednn_extra_args[idx]['name'] + ) + + return attr_str + + def AutoCodeGen(op_info_items, all_op_info_items, namespaces, dialect_name): # (3) CodeGen: Traverse op_info_items and generate ops_name_list = [] # all op class name store in this list @@ -1676,12 +1766,24 @@ def AutoCodeGen(op_info_items, all_op_info_items, namespaces, dialect_name): data_format_tensors = ( '"' + '", "'.join(data_format_tensors) + '"' ) + if ( + op_info.onednn_extra_args is not None + and len(op_info.onednn_extra_args) > 0 + ): + extra_attr_default_value_code_str = ( + GenOneDnnExtraAttrsDefaultValue( + op_info.onednn_extra_args + ) + ) + else: + extra_attr_default_value_code_str = "" op_info_func_str = OP_INFO_ONEDNN_TEMPLATE.format( op_name=op_class_name, inputs=inputs_info_str, attributes=attribute_info_str, outputs=outputs_info_str, + extra_attr_default_value_code=extra_attr_default_value_code_str, infer_meta_func=infer_meta_func_str, infer_meta_param=infer_meta_param_str, kernel_func=kernel_func_str, diff --git a/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h b/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h index 0f045cb97a0ec0..e0413b82e36852 100644 --- a/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h +++ b/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h @@ -14,6 +14,9 @@ #pragma once +#include +#include + #include "paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h" #include "paddle/pir/core/op_base.h" diff --git a/paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h b/paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h index da37d8b1d0929c..692176caae034f 100644 --- a/paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h +++ b/paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h @@ -17,6 +17,7 @@ #include "paddle/fluid/pir/dialect/operator/ir/type_storage.h" #include "paddle/pir/core/builtin_attribute.h" #include "paddle/pir/core/builtin_type.h" +#include "paddle/pir/core/operation_utils.h" namespace paddle { namespace dialect { @@ -94,6 +95,7 @@ struct OpRunTimeInfo { std::vector> inplace; std::vector> view; std::vector extra_args; + pir::AttributeMap extra_args_default_value; std::vector data_format_tensors; bool is_onednn_only; bool dynamic_fallback; @@ -107,6 +109,7 @@ struct OpRunTimeInfo { const std::vector>& inplace, const std::vector>& view, const std::vector& extra_args = {}, + const pir::AttributeMap& extra_args_default_value = {{}}, const std::vector& data_format_tensors = {}, bool is_onednn_only = false, bool dynamic_fallback = false) @@ -119,6 +122,7 @@ struct OpRunTimeInfo { inplace(inplace), view(view), extra_args(extra_args), + extra_args_default_value(extra_args_default_value), data_format_tensors(data_format_tensors), is_onednn_only(is_onednn_only), dynamic_fallback(dynamic_fallback) {} diff --git a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc index 65920c2820a23b..bcd2dce5954396 100644 --- a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc @@ -50,6 +50,7 @@ #include "paddle/utils/flags.h" #ifdef PADDLE_WITH_DNNL +#include "build/paddle/fluid/framework/framework.pb.h" #include "paddle/fluid/pir/dialect/operator/ir/onednn_op.h" #include "paddle/fluid/pir/dialect/operator/ir/op_onednn_dialect.h" #include "paddle/fluid/pir/dialect/operator/trait/onednn.h" @@ -855,6 +856,45 @@ bool SupportsMKLDNN(const std::string& kernel_name, } } } + +bool SupportsCPUBF16(const std::string& kernel_name) { + auto phi_kernels = + phi::KernelFactory::Instance().SelectKernelMap(kernel_name); + 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::CPU && + kern_pair.first.dtype() == phi::DataType::BFLOAT16; + }); + if (has_phi_kernel) { + return true; + } else { + auto op_kernel_iter = + paddle::framework::OperatorWithKernel::AllOpKernels().find( + phi::TransToFluidOpName(kernel_name)); + if (op_kernel_iter == + paddle::framework::OperatorWithKernel::AllOpKernels().end()) { + return false; + } else { + auto& op_kernels = op_kernel_iter->second; + return std::any_of( + op_kernels.begin(), + op_kernels.end(), + [](std::unordered_map< + paddle::framework::OpKernelType, + std::function, + paddle::framework::OpKernelType::Hash>::const_reference + kern_pair) { + return platform::is_cpu_place(kern_pair.first.place_) && + kern_pair.first.place_ == platform::CPUPlace() && + kern_pair.first.data_type_ == + paddle::framework::proto::VarType::Type:: + VarType_Type_BF16; + }); + } + } +} #endif phi::KernelKey GetKernelKey( @@ -2436,6 +2476,48 @@ void ProcessBlock( op_item = op_item_inner; op_info_parser = GetOpYamlInfoParser(op_item_inner); } + + // Use OneDNN if CPU not support bf16 + if (!op_item->HasTrait() && + kernel_key.backend() == phi::Backend::CPU && + !SupportsCPUBF16(kernel_name) && + SupportsMKLDNN(kernel_name, phi::DataType::BFLOAT16)) { + std::vector op_item_inner_output_types; + if (op_item->num_results() > 0) { + for (size_t i = 0; i < op_item->num_results(); ++i) { + op_item_inner_output_types.push_back(op_item->result_type(i)); + } + } + std::string target_op_name = op_item->name(); + target_op_name.replace(0, 5, "onednn_op"); + auto op_info = ctx->GetRegisteredOpInfo(target_op_name); + if (!op_info) { + IR_THROW("Ctx should have corresponding OpInfo %s", target_op_name); + } + auto attributes = op_item->attributes(); + auto yaml_interface = + op_info.GetInterfaceImpl(); + OpRunTimeInfo runtime_info = + std::get<3>(yaml_interface->get_op_info_(target_op_name)); + for (auto& attr : runtime_info.extra_args_default_value) { + attributes[attr.first] = attr.second; + } + pir::Operation* op_item_inner = + pir::Operation::Create(op_item->operands_source(), + attributes, + op_item_inner_output_types, + op_info); + op_item->ReplaceAllUsesWith(op_item_inner->results()); + for (auto iter = block->begin(); iter != block->end(); ++iter) { + if (*iter == *op_item) { + block->Assign(iter, op_item_inner); + break; + } + } + op_item = op_item_inner; + op_info_parser = GetOpYamlInfoParser(op_item_inner); + kernel_key.set_backend(phi::Backend::ONEDNN); + } #endif // build input auto new_vec_inputs = BuildInputs(op_item, From 77ecd47f861e08893816b641437fee7dd57bbfd8 Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Sun, 4 Feb 2024 11:41:10 +0000 Subject: [PATCH 2/7] refine --- paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml | 2 +- test/mkldnn/test_bilinear_interp_v2_mkldnn_op.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml b/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml index ec967b1d23ce5e..360b7275956589 100644 --- a/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml +++ b/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml @@ -27,7 +27,7 @@ extra_args : bool fuse_with_relu=false data_format_tensors : x, out_grad -# - op : bilinear_interp +- op : bilinear_interp # - op : cast diff --git a/test/mkldnn/test_bilinear_interp_v2_mkldnn_op.py b/test/mkldnn/test_bilinear_interp_v2_mkldnn_op.py index 42a5751945a02d..eca6ef8b9c7b0e 100644 --- a/test/mkldnn/test_bilinear_interp_v2_mkldnn_op.py +++ b/test/mkldnn/test_bilinear_interp_v2_mkldnn_op.py @@ -150,7 +150,7 @@ def setUp(self): self.outputs = {'Out': output_np} def test_check_output(self): - self.check_output(check_dygraph=False) + self.check_output(check_dygraph=False, check_pir_onednn=True) class TestBilinearInterpOpOneDNNNHWC(TestBilinearInterpOneDNNOp): From 17a8874f89ce42e9d330a771c44c04f84c9fc29a Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Mon, 5 Feb 2024 02:10:30 +0000 Subject: [PATCH 3/7] refine --- .../pir/transforms/pd_op_to_kernel_pass.cc | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc index bcd2dce5954396..38a3853eaafc73 100644 --- a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc @@ -2482,41 +2482,40 @@ void ProcessBlock( kernel_key.backend() == phi::Backend::CPU && !SupportsCPUBF16(kernel_name) && SupportsMKLDNN(kernel_name, phi::DataType::BFLOAT16)) { - std::vector op_item_inner_output_types; - if (op_item->num_results() > 0) { - for (size_t i = 0; i < op_item->num_results(); ++i) { - op_item_inner_output_types.push_back(op_item->result_type(i)); - } - } std::string target_op_name = op_item->name(); target_op_name.replace(0, 5, "onednn_op"); auto op_info = ctx->GetRegisteredOpInfo(target_op_name); - if (!op_info) { - IR_THROW("Ctx should have corresponding OpInfo %s", target_op_name); - } - auto attributes = op_item->attributes(); - auto yaml_interface = - op_info.GetInterfaceImpl(); - OpRunTimeInfo runtime_info = - std::get<3>(yaml_interface->get_op_info_(target_op_name)); - for (auto& attr : runtime_info.extra_args_default_value) { - attributes[attr.first] = attr.second; - } - pir::Operation* op_item_inner = - pir::Operation::Create(op_item->operands_source(), - attributes, - op_item_inner_output_types, - op_info); - op_item->ReplaceAllUsesWith(op_item_inner->results()); - for (auto iter = block->begin(); iter != block->end(); ++iter) { - if (*iter == *op_item) { - block->Assign(iter, op_item_inner); - break; + if (op_info) { + std::vector op_item_inner_output_types; + if (op_item->num_results() > 0) { + for (size_t i = 0; i < op_item->num_results(); ++i) { + op_item_inner_output_types.push_back(op_item->result_type(i)); + } } + auto attributes = op_item->attributes(); + auto yaml_interface = + op_info.GetInterfaceImpl(); + OpRunTimeInfo runtime_info = + std::get<3>(yaml_interface->get_op_info_(target_op_name)); + for (auto& attr : runtime_info.extra_args_default_value) { + attributes[attr.first] = attr.second; + } + pir::Operation* op_item_inner = + pir::Operation::Create(op_item->operands_source(), + attributes, + op_item_inner_output_types, + op_info); + op_item->ReplaceAllUsesWith(op_item_inner->results()); + for (auto iter = block->begin(); iter != block->end(); ++iter) { + if (*iter == *op_item) { + block->Assign(iter, op_item_inner); + break; + } + } + op_item = op_item_inner; + op_info_parser = GetOpYamlInfoParser(op_item_inner); + kernel_key.set_backend(phi::Backend::ONEDNN); } - op_item = op_item_inner; - op_info_parser = GetOpYamlInfoParser(op_item_inner); - kernel_key.set_backend(phi::Backend::ONEDNN); } #endif // build input From 02b13791ffcdd92489fe06d0291b614e31fdc916 Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Mon, 5 Feb 2024 02:57:57 +0000 Subject: [PATCH 4/7] refine --- paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml | 1 + paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml b/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml index 360b7275956589..55cda8e9372c36 100644 --- a/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml +++ b/paddle/fluid/pir/dialect/operator/ir/ops_onednn_extra.yaml @@ -28,6 +28,7 @@ data_format_tensors : x, out_grad - op : bilinear_interp + data_format_tensors : x # - op : cast diff --git a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc index 38a3853eaafc73..899718c0a63dd4 100644 --- a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc @@ -2486,6 +2486,7 @@ void ProcessBlock( target_op_name.replace(0, 5, "onednn_op"); auto op_info = ctx->GetRegisteredOpInfo(target_op_name); if (op_info) { + std::cout << "lalalala trans to " << target_op_name << std::endl; std::vector op_item_inner_output_types; if (op_item->num_results() > 0) { for (size_t i = 0; i < op_item->num_results(); ++i) { From 466520f196aa1a9f4deb7ffdb2c8f05a09dfb525 Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Mon, 5 Feb 2024 07:39:22 +0000 Subject: [PATCH 5/7] refine --- paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc index 899718c0a63dd4..fd8d724aad764f 100644 --- a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc @@ -1834,8 +1834,8 @@ std::vector BuildOutputs( std::vector op_output_types; pir::AttributeMap attribute_map = op_item->attributes(); - auto phi_kernel = phi::KernelFactory::Instance().SelectKernelWithGPUDNN( - kernel_fn_str, kernel_key); + auto phi_kernel = + phi::KernelFactory::Instance().SelectKernel(kernel_fn_str, kernel_key); VLOG(6) << "[" << kernel_fn_str << "] selected kernel(is_valid: " << phi_kernel.IsValid() << " ): " << kernel_key; @@ -2486,7 +2486,6 @@ void ProcessBlock( target_op_name.replace(0, 5, "onednn_op"); auto op_info = ctx->GetRegisteredOpInfo(target_op_name); if (op_info) { - std::cout << "lalalala trans to " << target_op_name << std::endl; std::vector op_item_inner_output_types; if (op_item->num_results() > 0) { for (size_t i = 0; i < op_item->num_results(); ++i) { From 1bba2e3d7db12e362ce6312f6b09c0e20111041d Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Mon, 5 Feb 2024 07:41:53 +0000 Subject: [PATCH 6/7] refine --- paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h b/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h index e0413b82e36852..0f045cb97a0ec0 100644 --- a/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h +++ b/paddle/fluid/pir/dialect/operator/interface/op_yaml_info.h @@ -14,9 +14,6 @@ #pragma once -#include -#include - #include "paddle/fluid/pir/dialect/operator/utils/op_yaml_info_util.h" #include "paddle/pir/core/op_base.h" From 3065b144918638ad36eb17a96c53bddb588d7c9b Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Mon, 5 Feb 2024 10:34:24 +0000 Subject: [PATCH 7/7] refine --- paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc index c94640a5f287f7..0ed48307a356ac 100644 --- a/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc @@ -2479,9 +2479,9 @@ void ProcessBlock( } // Use OneDNN if CPU not support bf16 - if (!op_item->HasTrait() && + if (kernel_key.dtype() == phi::DataType::BFLOAT16 && kernel_key.backend() == phi::Backend::CPU && - !SupportsCPUBF16(kernel_name) && + !op_item->HasTrait() && !SupportsCPUBF16(kernel_name) && SupportsMKLDNN(kernel_name, phi::DataType::BFLOAT16)) { std::string target_op_name = op_item->name(); target_op_name.replace(0, 5, "onednn_op");