From 664199aac97cb164d329accf844c4832d68a47d1 Mon Sep 17 00:00:00 2001 From: Allen Guo Date: Mon, 11 Apr 2022 19:44:31 +0800 Subject: [PATCH] fix running error for ipu (#41533) cherry from #41481 --- paddle/phi/common/backend.h | 7 +++++++ paddle/phi/core/compat/convert_utils.cc | 2 ++ 2 files changed, 9 insertions(+) diff --git a/paddle/phi/common/backend.h b/paddle/phi/common/backend.h index a9e12f5d81e..5543bee144b 100644 --- a/paddle/phi/common/backend.h +++ b/paddle/phi/common/backend.h @@ -55,6 +55,8 @@ enum class Backend : uint8_t { // paddle kernel primitives backend KPS, + IPU, + // end of backend types NUM_BACKENDS, @@ -121,6 +123,9 @@ inline std::ostream& operator<<(std::ostream& os, Backend backend) { case Backend::KPS: os << "KPS"; break; + case Backend::IPU: + os << "IPU"; + break; default: { size_t device_type_id_ = static_cast(backend) - static_cast(Backend::NUM_BACKENDS); @@ -155,6 +160,8 @@ inline Backend StringToBackend(const char* backend_cstr) { return Backend::GPUDNN; } else if (s == std::string("KPS")) { return Backend::KPS; + } else if (s == std::string("IPU")) { + return Backend::IPU; } else { return static_cast(static_cast(Backend::NUM_BACKENDS) + phi::GetOrRegisterGlobalDeviceTypeId(s)); diff --git a/paddle/phi/core/compat/convert_utils.cc b/paddle/phi/core/compat/convert_utils.cc index c08dfa64c7f..43febb2ac04 100644 --- a/paddle/phi/core/compat/convert_utils.cc +++ b/paddle/phi/core/compat/convert_utils.cc @@ -38,6 +38,8 @@ Backend TransToPhiBackend(const phi::Place& place) { return Backend::XPU; } else if (allocation_type == phi::AllocationType::NPU) { return Backend::NPU; + } else if (allocation_type == phi::AllocationType::IPU) { + return Backend::IPU; } else if (allocation_type == phi::AllocationType::CUSTOM) { return static_cast( static_cast(Backend::NUM_BACKENDS) + -- GitLab