From 3a66627e1b2c17a948a178313ba0f168d8446c07 Mon Sep 17 00:00:00 2001 From: zhangyuqin1998 <75946871+zhangyuqin1998@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:27:09 +0800 Subject: [PATCH] rename PD_REGISTER_GENERAL_KERNEL (#52759) * rename PD_REGISTER_GENERAL_KERNEL * Update feed_op.cc * fix * Update strings_empty_kernel.cc --- cmake/operators.cmake | 9 +- cmake/phi.cmake | 4 +- paddle/fluid/operators/controlflow/feed_op.cc | 74 +++----------- paddle/phi/core/kernel_registry.h | 26 ++--- paddle/phi/kernels/assign_kernel.cc | 72 +++++++------- paddle/phi/kernels/memcpy_kernel.cc | 99 +++++++++---------- paddle/phi/kernels/reshape_grad_kernel.cc | 55 ++--------- .../kernels/selected_rows/assign_kernel.cc | 27 +++-- paddle/phi/kernels/share_buffer_kernel.cc | 24 +---- .../strings/cpu/strings_copy_kernel.cc | 9 +- .../strings/cpu/strings_lower_upper_kernel.cc | 22 ++--- .../strings/gpu/strings_copy_kernel.cu | 9 +- .../strings/gpu/strings_lower_upper_kernel.cu | 22 ++--- .../kernels/strings/strings_empty_kernel.cc | 40 ++++---- paddle/phi/kernels/transfer_layout_kernel.cc | 18 ++-- 15 files changed, 195 insertions(+), 315 deletions(-) diff --git a/cmake/operators.cmake b/cmake/operators.cmake index 4935f90a73c..92906235032 100644 --- a/cmake/operators.cmake +++ b/cmake/operators.cmake @@ -368,7 +368,8 @@ function(op_library TARGET) # Add PHI Kernel Registry Message find_phi_register(${cc_src} ${pybind_file} "PD_REGISTER_KERNEL") find_phi_register(${cc_src} ${pybind_file} "PD_REGISTER_STRUCT_KERNEL") - find_phi_register(${cc_src} ${pybind_file} "PD_REGISTER_GENERAL_KERNEL") + find_phi_register(${cc_src} ${pybind_file} + "PD_REGISTER_KERNEL_FOR_ALL_DTYPE") find_register(${cc_src} "REGISTER_OPERATOR" op_name) if(NOT ${op_name} EQUAL "") file(APPEND ${pybind_file} "USE_OP_ITSELF(${op_name});\n") @@ -420,7 +421,8 @@ function(op_library TARGET) # Add PHI Kernel Registry Message find_phi_register(${cu_src} ${pybind_file} "PD_REGISTER_KERNEL") find_phi_register(${cu_src} ${pybind_file} "PD_REGISTER_STRUCT_KERNEL") - find_phi_register(${cu_src} ${pybind_file} "PD_REGISTER_GENERAL_KERNEL") + find_phi_register(${cu_src} ${pybind_file} + "PD_REGISTER_KERNEL_FOR_ALL_DTYPE") find_register(${cu_src} "REGISTER_OP_CUDA_KERNEL" op_name) if(NOT ${op_name} EQUAL "") file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n") @@ -436,7 +438,8 @@ function(op_library TARGET) find_register(${hip_src} "REGISTER_OP_CUDA_KERNEL" op_name) find_phi_register(${hip_src} ${pybind_file} "PD_REGISTER_KERNEL") find_phi_register(${hip_src} ${pybind_file} "PD_REGISTER_STRUCT_KERNEL") - find_phi_register(${hip_src} ${pybind_file} "PD_REGISTER_GENERAL_KERNEL") + find_phi_register(${hip_src} ${pybind_file} + "PD_REGISTER_KERNEL_FOR_ALL_DTYPE") if(NOT ${op_name} EQUAL "") file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n") set(pybind_flag 1) diff --git a/cmake/phi.cmake b/cmake/phi.cmake index bdb6a4f4252..96760969adf 100644 --- a/cmake/phi.cmake +++ b/cmake/phi.cmake @@ -78,7 +78,7 @@ function(kernel_declare TARGET_LIST) string( REGEX MATCH - "(PD_REGISTER_KERNEL|PD_REGISTER_GENERAL_KERNEL|PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE)\\([ \t\r\n]*[a-z0-9_]*,[[ \\\t\r\n\/]*[a-z0-9_]*]?[ \\\t\r\n]*[a-zA-Z_]*,[ \\\t\r\n]*[A-Z_]*" + "(PD_REGISTER_KERNEL|PD_REGISTER_KERNEL_FOR_ALL_DTYPE|PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE)\\([ \t\r\n]*[a-z0-9_]*,[[ \\\t\r\n\/]*[a-z0-9_]*]?[ \\\t\r\n]*[a-zA-Z_]*,[ \\\t\r\n]*[A-Z_]*" first_registry "${kernel_impl}") if(NOT first_registry STREQUAL "") @@ -108,7 +108,7 @@ function(kernel_declare TARGET_LIST) string(REPLACE "PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(" "" kernel_msg "${first_registry}") string(REPLACE "PD_REGISTER_KERNEL(" "" kernel_msg "${kernel_msg}") - string(REPLACE "PD_REGISTER_GENERAL_KERNEL(" "" kernel_msg + string(REPLACE "PD_REGISTER_KERNEL_FOR_ALL_DTYPE(" "" kernel_msg "${kernel_msg}") string(REPLACE "," ";" kernel_msg "${kernel_msg}") string(REGEX REPLACE "[ \\\t\r\n]+" "" kernel_msg "${kernel_msg}") diff --git a/paddle/fluid/operators/controlflow/feed_op.cc b/paddle/fluid/operators/controlflow/feed_op.cc index 4352d58047e..698ca4e02e6 100644 --- a/paddle/fluid/operators/controlflow/feed_op.cc +++ b/paddle/fluid/operators/controlflow/feed_op.cc @@ -212,77 +212,29 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, paddle::operators::FeedOpInfoMaker); -PD_REGISTER_GENERAL_KERNEL( - feed_dense_tensor, - CPU, - ALL_LAYOUT, - paddle::operators::FeedDenseTensorKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL( +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( feed_sparse_coo_tensor, CPU, ALL_LAYOUT, - paddle::operators::FeedSparseCooTensorKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL( - feed_strings, - CPU, - ALL_LAYOUT, - paddle::operators::FeedStringsKernel, - ALL_DTYPE) {} + paddle::operators::FeedSparseCooTensorKernel) {} #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL( - feed_dense_tensor, - GPU, - ALL_LAYOUT, - paddle::operators::FeedDenseTensorKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL( +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( feed_sparse_coo_tensor, GPU, ALL_LAYOUT, - paddle::operators::FeedSparseCooTensorKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL( - feed_strings, - GPU, - ALL_LAYOUT, - paddle::operators::FeedStringsKernel, - ALL_DTYPE) {} + paddle::operators::FeedSparseCooTensorKernel) {} #elif defined(PADDLE_WITH_XPU) -PD_REGISTER_GENERAL_KERNEL( - feed_dense_tensor, - XPU, - ALL_LAYOUT, - paddle::operators::FeedDenseTensorKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL( +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( feed_sparse_coo_tensor, XPU, ALL_LAYOUT, - paddle::operators::FeedSparseCooTensorKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL( - feed_strings, - XPU, - ALL_LAYOUT, - paddle::operators::FeedStringsKernel, - ALL_DTYPE) {} -#endif -#ifdef PADDLE_WITH_CUSTOM_DEVICE -PD_REGISTER_GENERAL_KERNEL( - feed_dense_tensor, - Custom, - ALL_LAYOUT, - paddle::operators::FeedDenseTensorKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL( - feed_strings, - Custom, - ALL_LAYOUT, - paddle::operators::FeedStringsKernel, - ALL_DTYPE) {} + paddle::operators::FeedSparseCooTensorKernel) {} #endif + +PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE( + feed_dense_tensor, ALL_LAYOUT, paddle::operators::FeedDenseTensorKernel) {} +PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(feed_strings, + ALL_LAYOUT, + paddle::operators::FeedStringsKernel) { +} diff --git a/paddle/phi/core/kernel_registry.h b/paddle/phi/core/kernel_registry.h index af187f57aec..9f45c23dac9 100644 --- a/paddle/phi/core/kernel_registry.h +++ b/paddle/phi/core/kernel_registry.h @@ -1326,28 +1326,28 @@ struct KernelRegistrar { kernel_unfold_macro, \ variadic_kernel_unfold_marco, \ __VA_ARGS__)) -/** PD_REGISTER_GENERAL_KERNEL +/** PD_REGISTER_KERNEL_FOR_ALL_DTYPE * * Basic Kernel register marco, used to register a instantiated kernel function * with one template argument. */ -#define PD_REGISTER_GENERAL_KERNEL( \ - kernel_name, backend, layout, kernel_fn, dtype) \ - _PD_REGISTER_GENERAL_KERNEL( \ - ::phi::RegType::INNER, kernel_name, backend, layout, kernel_fn, dtype) +#define PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + kernel_name, backend, layout, kernel_fn) \ + _PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + ::phi::RegType::INNER, kernel_name, backend, layout, kernel_fn) -#define _PD_REGISTER_GENERAL_KERNEL( \ - reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ +#define _PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + reg_type, kernel_name, backend, layout, kernel_fn) \ PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \ PD_REGISTER_no_t_kernel_ns_check_##kernel_name##_##backend##_##layout, \ "PD_REGISTER_NO_TEMPLATE_KERNEL must be called in global namespace."); \ - __PD_REGISTER_GENERAL_KERNEL( \ - reg_type, kernel_name, backend, layout, kernel_fn, dtype) + __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + reg_type, kernel_name, backend, layout, kernel_fn) #ifndef _WIN32 -#define __PD_REGISTER_GENERAL_KERNEL( \ - reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ +#define __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + reg_type, kernel_name, backend, layout, kernel_fn) \ template decltype(kernel_fn) kernel_fn; \ static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \ @@ -1367,8 +1367,8 @@ struct KernelRegistrar { void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel) #else -#define __PD_REGISTER_GENERAL_KERNEL( \ - reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ +#define __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \ + reg_type, kernel_name, backend, layout, kernel_fn) \ static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \ static const ::phi::KernelRegistrar \ diff --git a/paddle/phi/kernels/assign_kernel.cc b/paddle/phi/kernels/assign_kernel.cc index 9aba3bcb78f..7a6e8d392da 100644 --- a/paddle/phi/kernels/assign_kernel.cc +++ b/paddle/phi/kernels/assign_kernel.cc @@ -108,21 +108,21 @@ void AssignValueKernel(const Context& dev_ctx, } // namespace phi -PD_REGISTER_GENERAL_KERNEL( - assign, CPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign, + CPU, + ALL_LAYOUT, + phi::AssignKernel) {} -PD_REGISTER_GENERAL_KERNEL(assign_raw, - CPU, - ALL_LAYOUT, - phi::AssignRawKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw, + CPU, + ALL_LAYOUT, + phi::AssignRawKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } -PD_REGISTER_GENERAL_KERNEL(assign_array, - CPU, - ALL_LAYOUT, - phi::AssignArrayKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array, + CPU, + ALL_LAYOUT, + phi::AssignArrayKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } PD_REGISTER_KERNEL(assign_value, @@ -135,20 +135,20 @@ PD_REGISTER_KERNEL(assign_value, int64_t) {} #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL( - assign, GPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(assign_raw, - GPU, - ALL_LAYOUT, - phi::AssignRawKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign, + GPU, + ALL_LAYOUT, + phi::AssignKernel) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw, + GPU, + ALL_LAYOUT, + phi::AssignRawKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } -PD_REGISTER_GENERAL_KERNEL(assign_array, - GPU, - ALL_LAYOUT, - phi::AssignArrayKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array, + GPU, + ALL_LAYOUT, + phi::AssignArrayKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } PD_REGISTER_KERNEL(assign_value, @@ -162,20 +162,20 @@ PD_REGISTER_KERNEL(assign_value, #endif #ifdef PADDLE_WITH_XPU -PD_REGISTER_GENERAL_KERNEL( - assign, XPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(assign_raw, - XPU, - ALL_LAYOUT, - phi::AssignRawKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign, + XPU, + ALL_LAYOUT, + phi::AssignKernel) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw, + XPU, + ALL_LAYOUT, + phi::AssignRawKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } -PD_REGISTER_GENERAL_KERNEL(assign_array, - XPU, - ALL_LAYOUT, - phi::AssignArrayKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array, + XPU, + ALL_LAYOUT, + phi::AssignArrayKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } PD_REGISTER_KERNEL(assign_value, diff --git a/paddle/phi/kernels/memcpy_kernel.cc b/paddle/phi/kernels/memcpy_kernel.cc index cf2f6ac00a6..49d69a23fed 100644 --- a/paddle/phi/kernels/memcpy_kernel.cc +++ b/paddle/phi/kernels/memcpy_kernel.cc @@ -136,83 +136,78 @@ void MemcpyKernel(const Context& dev_ctx, } // namespace phi -PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, - CPU, - ALL_LAYOUT, - phi::MemcpyH2DKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, - CPU, - ALL_LAYOUT, - phi::MemcpyD2HKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d, + CPU, + ALL_LAYOUT, + phi::MemcpyH2DKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h, + CPU, + ALL_LAYOUT, + phi::MemcpyD2HKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, - CPU, - ALL_LAYOUT, - phi::MemcpyD2HMultiIOKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io, + CPU, + ALL_LAYOUT, + phi::MemcpyD2HMultiIOKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } -PD_REGISTER_GENERAL_KERNEL( - memcpy, CPU, ALL_LAYOUT, phi::MemcpyKernel, ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy, + CPU, + ALL_LAYOUT, + phi::MemcpyKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, - GPU, - ALL_LAYOUT, - phi::MemcpyH2DKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, - GPU, - ALL_LAYOUT, - phi::MemcpyD2HKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d, + GPU, + ALL_LAYOUT, + phi::MemcpyH2DKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h, + GPU, + ALL_LAYOUT, + phi::MemcpyD2HKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, - GPU, - ALL_LAYOUT, - phi::MemcpyD2HMultiIOKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io, + GPU, + ALL_LAYOUT, + phi::MemcpyD2HMultiIOKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } -PD_REGISTER_GENERAL_KERNEL( - memcpy, GPU, ALL_LAYOUT, phi::MemcpyKernel, ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy, + GPU, + ALL_LAYOUT, + phi::MemcpyKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } #endif #ifdef PADDLE_WITH_XPU -PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, - XPU, - ALL_LAYOUT, - phi::MemcpyH2DKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, - XPU, - ALL_LAYOUT, - phi::MemcpyD2HKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d, + XPU, + ALL_LAYOUT, + phi::MemcpyH2DKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h, + XPU, + ALL_LAYOUT, + phi::MemcpyD2HKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } -PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, - XPU, - ALL_LAYOUT, - phi::MemcpyD2HMultiIOKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io, + XPU, + ALL_LAYOUT, + phi::MemcpyD2HMultiIOKernel) { kernel->OutputAt(0).SetBackend(phi::Backend::CPU); } diff --git a/paddle/phi/kernels/reshape_grad_kernel.cc b/paddle/phi/kernels/reshape_grad_kernel.cc index 70dab5d9bb9..ef4c7d4a6f7 100644 --- a/paddle/phi/kernels/reshape_grad_kernel.cc +++ b/paddle/phi/kernels/reshape_grad_kernel.cc @@ -61,52 +61,9 @@ void ReshapeDoubleGradKernel(const Context& dev_ctx, } // namespace phi -PD_REGISTER_GENERAL_KERNEL(reshape_grad, - CPU, - ALL_LAYOUT, - phi::ReshapeGradKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(reshape_double_grad, - CPU, - ALL_LAYOUT, - phi::ReshapeDoubleGradKernel, - ALL_DTYPE) {} - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(reshape_grad, - GPU, - ALL_LAYOUT, - phi::ReshapeGradKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(reshape_double_grad, - GPU, - ALL_LAYOUT, - phi::ReshapeDoubleGradKernel, - ALL_DTYPE) {} -#endif - -#ifdef PADDLE_WITH_XPU -PD_REGISTER_GENERAL_KERNEL(reshape_grad, - XPU, - ALL_LAYOUT, - phi::ReshapeGradKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(reshape_double_grad, - XPU, - ALL_LAYOUT, - phi::ReshapeDoubleGradKernel, - ALL_DTYPE) {} -#endif - -#ifdef PADDLE_WITH_CUSTOM_DEVICE -PD_REGISTER_GENERAL_KERNEL(reshape_grad, - Custom, - ALL_LAYOUT, - phi::ReshapeGradKernel, - ALL_DTYPE) {} -PD_REGISTER_GENERAL_KERNEL(reshape_double_grad, - Custom, - ALL_LAYOUT, - phi::ReshapeDoubleGradKernel, - ALL_DTYPE) {} -#endif +PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(reshape_grad, + ALL_LAYOUT, + phi::ReshapeGradKernel) {} +PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(reshape_double_grad, + ALL_LAYOUT, + phi::ReshapeDoubleGradKernel) {} diff --git a/paddle/phi/kernels/selected_rows/assign_kernel.cc b/paddle/phi/kernels/selected_rows/assign_kernel.cc index 32045d3106f..081d85e68c9 100644 --- a/paddle/phi/kernels/selected_rows/assign_kernel.cc +++ b/paddle/phi/kernels/selected_rows/assign_kernel.cc @@ -34,30 +34,27 @@ void AssignKernel(const Context& dev_ctx, } // namespace sr } // namespace phi -PD_REGISTER_GENERAL_KERNEL(assign_sr, - CPU, - ALL_LAYOUT, - phi::sr::AssignKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr, + CPU, + ALL_LAYOUT, + phi::sr::AssignKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(assign_sr, - GPU, - ALL_LAYOUT, - phi::sr::AssignKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr, + GPU, + ALL_LAYOUT, + phi::sr::AssignKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } #endif #ifdef PADDLE_WITH_XPU -PD_REGISTER_GENERAL_KERNEL(assign_sr, - XPU, - ALL_LAYOUT, - phi::sr::AssignKernel, - ALL_DTYPE) { +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr, + XPU, + ALL_LAYOUT, + phi::sr::AssignKernel) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } #endif diff --git a/paddle/phi/kernels/share_buffer_kernel.cc b/paddle/phi/kernels/share_buffer_kernel.cc index d428de38637..dd4272a591b 100644 --- a/paddle/phi/kernels/share_buffer_kernel.cc +++ b/paddle/phi/kernels/share_buffer_kernel.cc @@ -46,24 +46,6 @@ void ShareBufferKernel(const Context &dev_ctx, } // namespace phi -PD_REGISTER_GENERAL_KERNEL(share_buffer, - CPU, - ALL_LAYOUT, - phi::ShareBufferKernel, - ALL_DTYPE) {} - -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(share_buffer, - GPU, - ALL_LAYOUT, - phi::ShareBufferKernel, - ALL_DTYPE) {} -#endif - -#ifdef PADDLE_WITH_XPU -PD_REGISTER_GENERAL_KERNEL(share_buffer, - XPU, - ALL_LAYOUT, - phi::ShareBufferKernel, - ALL_DTYPE) {} -#endif +PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(share_buffer, + ALL_LAYOUT, + phi::ShareBufferKernel) {} diff --git a/paddle/phi/kernels/strings/cpu/strings_copy_kernel.cc b/paddle/phi/kernels/strings/cpu/strings_copy_kernel.cc index cd6e5fadd49..da8fba85acc 100644 --- a/paddle/phi/kernels/strings/cpu/strings_copy_kernel.cc +++ b/paddle/phi/kernels/strings/cpu/strings_copy_kernel.cc @@ -53,8 +53,7 @@ void Copy(const Context& dev_ctx, } // namespace strings } // namespace phi -PD_REGISTER_GENERAL_KERNEL(strings_copy, - CPU, - ALL_LAYOUT, - phi::strings::Copy, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy, + CPU, + ALL_LAYOUT, + phi::strings::Copy) {} diff --git a/paddle/phi/kernels/strings/cpu/strings_lower_upper_kernel.cc b/paddle/phi/kernels/strings/cpu/strings_lower_upper_kernel.cc index 9901496b2a6..b470f3b211f 100644 --- a/paddle/phi/kernels/strings/cpu/strings_lower_upper_kernel.cc +++ b/paddle/phi/kernels/strings/cpu/strings_lower_upper_kernel.cc @@ -43,14 +43,14 @@ void StringUpperKernel(const ContextT& dev_ctx, } // namespace strings } // namespace phi -PD_REGISTER_GENERAL_KERNEL(strings_lower, - CPU, - ALL_LAYOUT, - phi::strings::StringLowerKernel, - pstring) {} - -PD_REGISTER_GENERAL_KERNEL(strings_upper, - CPU, - ALL_LAYOUT, - phi::strings::StringUpperKernel, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_lower, + CPU, + ALL_LAYOUT, + phi::strings::StringLowerKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_upper, + CPU, + ALL_LAYOUT, + phi::strings::StringUpperKernel) {} diff --git a/paddle/phi/kernels/strings/gpu/strings_copy_kernel.cu b/paddle/phi/kernels/strings/gpu/strings_copy_kernel.cu index cfee8d56690..8f283f8b8eb 100644 --- a/paddle/phi/kernels/strings/gpu/strings_copy_kernel.cu +++ b/paddle/phi/kernels/strings/gpu/strings_copy_kernel.cu @@ -120,8 +120,7 @@ void Copy(const Context& dev_ctx, } // namespace strings } // namespace phi -PD_REGISTER_GENERAL_KERNEL(strings_copy, - GPU, - ALL_LAYOUT, - phi::strings::Copy, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy, + GPU, + ALL_LAYOUT, + phi::strings::Copy) {} diff --git a/paddle/phi/kernels/strings/gpu/strings_lower_upper_kernel.cu b/paddle/phi/kernels/strings/gpu/strings_lower_upper_kernel.cu index 2237edae7eb..832d9bbf73c 100644 --- a/paddle/phi/kernels/strings/gpu/strings_lower_upper_kernel.cu +++ b/paddle/phi/kernels/strings/gpu/strings_lower_upper_kernel.cu @@ -167,14 +167,14 @@ void StringUpperKernel(const ContextT& dev_ctx, } // namespace strings } // namespace phi -PD_REGISTER_GENERAL_KERNEL(strings_lower, - GPU, - ALL_LAYOUT, - phi::strings::StringLowerKernel, - pstring) {} - -PD_REGISTER_GENERAL_KERNEL(strings_upper, - GPU, - ALL_LAYOUT, - phi::strings::StringUpperKernel, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_lower, + GPU, + ALL_LAYOUT, + phi::strings::StringLowerKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_upper, + GPU, + ALL_LAYOUT, + phi::strings::StringUpperKernel) {} diff --git a/paddle/phi/kernels/strings/strings_empty_kernel.cc b/paddle/phi/kernels/strings/strings_empty_kernel.cc index 433d3ad0a95..22a43ceaff1 100644 --- a/paddle/phi/kernels/strings/strings_empty_kernel.cc +++ b/paddle/phi/kernels/strings/strings_empty_kernel.cc @@ -38,28 +38,26 @@ void EmptyLikeKernel(const Context& dev_ctx, StringTensor* out) { using pstring = ::phi::dtype::pstring; -PD_REGISTER_GENERAL_KERNEL(strings_empty, - CPU, - ALL_LAYOUT, - phi::strings::EmptyKernel, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty, + CPU, + ALL_LAYOUT, + phi::strings::EmptyKernel) {} -PD_REGISTER_GENERAL_KERNEL(strings_empty_like, - CPU, - ALL_LAYOUT, - phi::strings::EmptyLikeKernel, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_empty_like, + CPU, + ALL_LAYOUT, + phi::strings::EmptyLikeKernel) {} #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(strings_empty, - GPU, - ALL_LAYOUT, - phi::strings::EmptyKernel, - pstring) {} - -PD_REGISTER_GENERAL_KERNEL(strings_empty_like, - GPU, - ALL_LAYOUT, - phi::strings::EmptyLikeKernel, - pstring) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty, + GPU, + ALL_LAYOUT, + phi::strings::EmptyKernel) {} + +PD_REGISTER_KERNEL_FOR_ALL_DTYPE( + strings_empty_like, + GPU, + ALL_LAYOUT, + phi::strings::EmptyLikeKernel) {} #endif diff --git a/paddle/phi/kernels/transfer_layout_kernel.cc b/paddle/phi/kernels/transfer_layout_kernel.cc index df3d0ef4617..3d0b5950bc9 100644 --- a/paddle/phi/kernels/transfer_layout_kernel.cc +++ b/paddle/phi/kernels/transfer_layout_kernel.cc @@ -202,15 +202,13 @@ void TransferLayoutKernel(const Context& dev_ctx, } // namespace phi -PD_REGISTER_GENERAL_KERNEL(transfer_layout, - CPU, - ALL_LAYOUT, - phi::TransferLayoutKernel, - ALL_DTYPE) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout, + CPU, + ALL_LAYOUT, + phi::TransferLayoutKernel) {} #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -PD_REGISTER_GENERAL_KERNEL(transfer_layout, - GPU, - ALL_LAYOUT, - phi::TransferLayoutKernel, - ALL_DTYPE) {} +PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout, + GPU, + ALL_LAYOUT, + phi::TransferLayoutKernel) {} #endif -- GitLab