From 3158004b1b57b9bbb6393cd4ab8cdcea919ae694 Mon Sep 17 00:00:00 2001 From: jjyaoao <88936287+jjyaoao@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:49:19 +0000 Subject: [PATCH 1/2] delete SupportNPU(), SupportMLU() --- .../interpreter/interpreter_util.cc | 9 +------ paddle/fluid/framework/operator.cc | 27 ------------------- paddle/fluid/framework/operator.h | 14 ---------- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc index 0a93659cf9c16..5b0d2c6915e1f 100644 --- a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc +++ b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc @@ -390,14 +390,7 @@ void ApplyDeviceGuard(const OperatorBase* op_base, // when the Op that does not have NPUKernel is assigned to NPU, the // CPUKernel will be executed and a warning will be given at the same // time. - if (op_base->SupportNPU()) { - expected_kernel_key->place_ = place; - } else { - expected_kernel_key->place_ = platform::CPUPlace(); - LOG_FIRST_N(WARNING, 1) - << "Op(" << op_base->Type() - << ") has no NPU implementation. It will be assigned to CPUPlace."; - } + VLOG(3) << "Switch into " << expected_kernel_key->place_ << " by device_guard."; } else if (op_device.find("xpu") != std::string::npos && diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index ce40571ee0b96..c37a5260bcd6c 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1326,33 +1326,6 @@ bool OperatorWithKernel::SupportGPU() const { } } -bool OperatorWithKernel::SupportNPU() const { - auto phi_kernels = phi::KernelFactory::Instance().SelectKernelMap( - phi::TransToPhiKernelName(type_)); - 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::NPU; - }); - if (has_phi_kernel) { - return true; - } else { - auto kernel_iter = OperatorWithKernel::AllOpKernels().find(type_); - if (kernel_iter == OperatorWithKernel::AllOpKernels().end()) { - return false; - } else { - auto& op_kernels = kernel_iter->second; - return std::any_of( - op_kernels.begin(), - op_kernels.end(), - [](OpKernelMap::const_reference kern_pair) { - return platform::is_npu_place(kern_pair.first.place_); - }); - } - } -} - bool OperatorWithKernel::SupportXPU() const { #ifdef PADDLE_WITH_XPU auto phi_kernels = phi::KernelFactory::Instance().SelectKernelMap( diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index 495fc211f63d9..57ba880f4f2cd 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -285,8 +285,6 @@ class OperatorBase { std::string DebugString() const { return DebugStringEx(nullptr); } virtual bool SupportGPU() const { return false; } - virtual bool SupportNPU() const { return false; } - virtual bool SupportMLU() const { return false; } virtual bool SupportXPU() const { return false; } const std::string& Type() const { return type_; } @@ -746,18 +744,6 @@ class OperatorWithKernel : public OperatorBase { bool SupportGPU() const override; - bool SupportNPU() const override; - - bool SupportMLU() const override { - // TODO(zhiqiu): support phi if needed? - auto& op_kernels = OperatorWithKernel::AllOpKernels().at(type_); - return std::any_of(op_kernels.begin(), - op_kernels.end(), - [](OpKernelMap::const_reference kern_pair) { - return platform::is_mlu_place(kern_pair.first.place_); - }); - } - bool SupportXPU() const override; bool SupportsMKLDNN(phi::DataType data_type) const; From 60c8ce783d9c8d3b59afb2de44abe04b2c69c6b2 Mon Sep 17 00:00:00 2001 From: jjyaoao <88936287+jjyaoao@users.noreply.github.com> Date: Fri, 14 Apr 2023 04:18:49 +0000 Subject: [PATCH 2/2] delete npu branch --- .../new_executor/interpreter/interpreter_util.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc index 5b0d2c6915e1f..513b5f5cb3f87 100644 --- a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc +++ b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc @@ -383,14 +383,6 @@ void ApplyDeviceGuard(const OperatorBase* op_base, << "Op(" << op_base->Type() << ") has no CUDA implementation. It will be assigned to CPUPlace."; } - VLOG(3) << "Switch into " << expected_kernel_key->place_ - << " by device_guard."; - } else if (op_device.find("npu") != std::string::npos && - platform::is_npu_place(place)) { - // when the Op that does not have NPUKernel is assigned to NPU, the - // CPUKernel will be executed and a warning will be given at the same - // time. - VLOG(3) << "Switch into " << expected_kernel_key->place_ << " by device_guard."; } else if (op_device.find("xpu") != std::string::npos &&