Skip to content

Commit

Permalink
polish deetails
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwhql committed Dec 14, 2021
1 parent 1a8f018 commit d2bdad9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
38 changes: 19 additions & 19 deletions paddle/pten/common/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ namespace experimental {
enum class Backend : uint8_t {
UNDEFINED = 0,

// basic kernel backend
CPU,

// various acceleration devices' backends
CUDA,
XPU, // XPU currently does not exist at the same time as CUDA
NPU, // NPU currently does not exist at the same time as CUDA

// the third library backend
MKLDNN,
CUDNN,

// end of backend types
NUM_BACKENDS,

/**
* [ Why we need ALL in baisc kernel key member? ]
*
Expand All @@ -53,12 +68,12 @@ enum class Backend : uint8_t {
* so if we provide the ALL field with Register the kernel in this statement.
*
* Of course, we have also considered solving this problem through different
* named macros, for example, we define
* named macros, for example, if we define
*
* PT_REGISTER_KERNEL_FOR_ALL_BACKEND
*
* However, dtype and layout also have the same requirements, we need to
* define a series of macros
* Based on this design pattern, the dtype and layout also have the same
* requirements, this cause we need to define a series of macros
*
* PT_REGISTER_KERNEL_FOR_ALL_DTYPE
* PT_REGISTER_KERNEL_FOR_ALL_LAYOUT
Expand All @@ -67,28 +82,13 @@ enum class Backend : uint8_t {
* PT_REGISTER_KERNEL_FOR_ALL_LAYOUT_AND_DTYPE
* PT_REGISTER_KERNEL_FOR_ALL_BACKEND_AND_LAYOUT_AND_DTYPE
*
* This makes the system of registering macros more complicated, we think
* It makes the system of registering macros more complicated, we think
* this is not a simple design, so we still adopt the design of providing
* the ALL field.
*
* Note: ALL_BACKEND only used for Kernel registration and selection
*/
ALL_BACKEND = UNDEFINED,

// basic kernel backend
CPU,

// various acceleration devices' backends
CUDA,
XPU, // XPU currently does not exist at the same time as CUDA
NPU, // NPU currently does not exist at the same time as CUDA

// the third library backend
MKLDNN,
CUDNN,

// end of backend types
NUM_BACKENDS,
};

inline std::ostream& operator<<(std::ostream& os, Backend backend) {
Expand Down
6 changes: 3 additions & 3 deletions paddle/pten/common/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ using bfloat16 = ::paddle::platform::bfloat16;

enum class DataType {
UNDEFINED = 0,
// See Note [ Why we need ALL in baisc kernel key member? ]
ALL_DTYPE = UNDEFINED,
BOOL,
INT8, // Char
UINT8, // BYte
Expand All @@ -47,7 +45,9 @@ enum class DataType {
FLOAT64,
COMPLEX64,
COMPLEX128,
NUM_DATA_TYPES
NUM_DATA_TYPES,
// See Note [ Why we need ALL in baisc kernel key member? ]
ALL_DTYPE = UNDEFINED,
};

inline size_t SizeOf(DataType data_type) {
Expand Down
4 changes: 2 additions & 2 deletions paddle/pten/common/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace experimental {

enum class DataLayout {
UNDEFINED = 0,
// See Note [ Why we need ALL in baisc kernel key member? ]
ALL_LAYOUT = UNDEFINED,
// TODO(chenweihang): keep ANY for compatibility, remove it later
ANY = UNDEFINED,
NHWC,
NCHW,
MKLDNN,
NUM_DATA_LAYOUTS,
// See Note [ Why we need ALL in baisc kernel key member? ]
ALL_LAYOUT = UNDEFINED,
};

inline std::ostream& operator<<(std::ostream& os, DataLayout layout) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/pten/core/kernel_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct KernelRegistrar {
* pointer of the corresponding data type is automatically instantiated
* during registration.
*
* Note: If needed, add more marco to support 2 template arguments deduce
* Note: `1TA` means `1 template argument`
*/
#define PT_REGISTER_KERNEL( \
kernel_name, backend, layout, meta_kernel_fn, cpp_dtype, ...) \
Expand Down

1 comment on commit d2bdad9

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.