diff --git a/paddle/phi/common/backend.h b/paddle/phi/common/backend.h index c6d49bd5b978bf4b3fa7ec41f2568f72a7ea5afb..bfdc3814823183069a983bd46f4b31179e07bc1e 100644 --- a/paddle/phi/common/backend.h +++ b/paddle/phi/common/backend.h @@ -48,6 +48,7 @@ enum class Backend : uint8_t { XPU, // XPU currently does not exist at the same time as CUDA NPU, // NPU currently does not exist at the same time as CUDA MLU, // MLU currently does not exist at the same time as CUDA + IPU, // the third library backend ONEDNN, @@ -56,8 +57,6 @@ enum class Backend : uint8_t { // paddle kernel primitives backend KPS, - IPU, - // end of backend types NUM_BACKENDS, diff --git a/paddle/phi/common/layout.h b/paddle/phi/common/layout.h index 6b2f657699fb15f4d058121e3c2e12b46d3c59ad..2d74abeb84d641fd6ed23fc67a6c5d68c21e564d 100644 --- a/paddle/phi/common/layout.h +++ b/paddle/phi/common/layout.h @@ -18,8 +18,20 @@ limitations under the License. */ namespace paddle { namespace experimental { +// Note: The original design of paddle DataLayout is confusing. +// It contains two levels of "layout", one is the data layout +// at the Tensor level, including Dense, Sparse, etc., and the other +// is the format at the data level, including NHWC, NCHW, etc., +// these should belong to the concept of "data format". +// The concepts of these two levels are mixed into an enumeration class, +// which leads to some strange execution scheduling logic. +// It needs to be refactored in the future. +// In order to maintain compatibility, we still use the design of the +// original framework here. + // Note: Here the DataLayout is public api for external users, the prefix `k` // maybe confuse users, so we use all uppercase names + enum class DataLayout { UNDEFINED = 0, // TODO(chenweihang): keep ANY for compatibility, remove it later @@ -32,16 +44,21 @@ enum class DataLayout { SPARSE_COO, SPARSE_CSR, PSTRING_UNION, + NUM_DATA_LAYOUTS, + // See Note [ Why we need ALL in basic kernel key member? ] ALL_LAYOUT = UNDEFINED, + // Note: Unify phi DataLayout and fluid::framework::DataLayout, // for compatible with fluid DataLayout, here need prefix `k` + // Note: The original `kAnyLayout (enum value 2)` is a strange design. // `kAnyLayout` originally cannot represent any kind of Layout, // at the same time, it can also represent any Layout. // Strictly, it means "default" or "undefined" layout, - // and should not be mixed with other meaningful layouts. + // and should not be mixed with other meaningful layouts + kAnyLayout = ANY, kNHWC = NHWC, kNCHW = NCHW,