diff --git a/paddle/fluid/platform/device/xpu/xpu_op_list.cc b/paddle/fluid/platform/device/xpu/xpu_op_list.cc index 6127fcfa8def6f2a6723416c6a29bd41a4871b74..b20e8ac9785cafea7e4f85fbfb9570d3cde5d1f5 100644 --- a/paddle/fluid/platform/device/xpu/xpu_op_list.cc +++ b/paddle/fluid/platform/device/xpu/xpu_op_list.cc @@ -23,12 +23,9 @@ namespace paddle { namespace platform { bool is_xpu_support_op(const std::string& op_name, const pOpKernelType& type) { - auto& ops = get_kl1_ops(); auto v = get_xpu_version(type.place_.device); - if (v == phi::backends::xpu::XPUVersion::XPU2) { - ops = get_kl2_ops(); - } - + auto& ops = (v == phi::backends::xpu::XPUVersion::XPU1) ? get_kl1_ops() + : get_kl2_ops(); if (ops.find(op_name) != ops.end() && ops[op_name].find(type) != ops[op_name].end()) { return true; @@ -78,12 +75,9 @@ bool is_in_xpu_black_list(const std::string& op_name) { #ifdef PADDLE_WITH_XPU_KP bool is_xpu_kp_support_op(const std::string& op_name, const pOpKernelType& type) { - auto& ops = get_kl1_ops(); auto v = get_xpu_version(type.place_.device); - if (v == phi::backends::xpu::XPUVersion::XPU2) { - ops = get_kp_ops(); - } - + auto& ops = (v == phi::backends::xpu::XPUVersion::XPU1) ? get_kl1_ops() + : get_kp_ops(); if (ops.find(op_name) != ops.end() && ops[op_name].find(type) != ops[op_name].end()) { return true;