未验证 提交 3a66627e 编写于 作者: Z zhangyuqin1998 提交者: GitHub

rename PD_REGISTER_GENERAL_KERNEL (#52759)

* rename PD_REGISTER_GENERAL_KERNEL

* Update feed_op.cc

* fix

* Update strings_empty_kernel.cc
上级 2cff9839
...@@ -368,7 +368,8 @@ function(op_library TARGET) ...@@ -368,7 +368,8 @@ function(op_library TARGET)
# Add PHI Kernel Registry Message # Add PHI Kernel Registry Message
find_phi_register(${cc_src} ${pybind_file} "PD_REGISTER_KERNEL") 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_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) find_register(${cc_src} "REGISTER_OPERATOR" op_name)
if(NOT ${op_name} EQUAL "") if(NOT ${op_name} EQUAL "")
file(APPEND ${pybind_file} "USE_OP_ITSELF(${op_name});\n") file(APPEND ${pybind_file} "USE_OP_ITSELF(${op_name});\n")
...@@ -420,7 +421,8 @@ function(op_library TARGET) ...@@ -420,7 +421,8 @@ function(op_library TARGET)
# Add PHI Kernel Registry Message # Add PHI Kernel Registry Message
find_phi_register(${cu_src} ${pybind_file} "PD_REGISTER_KERNEL") 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_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) find_register(${cu_src} "REGISTER_OP_CUDA_KERNEL" op_name)
if(NOT ${op_name} EQUAL "") if(NOT ${op_name} EQUAL "")
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n") file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n")
...@@ -436,7 +438,8 @@ function(op_library TARGET) ...@@ -436,7 +438,8 @@ function(op_library TARGET)
find_register(${hip_src} "REGISTER_OP_CUDA_KERNEL" op_name) 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_KERNEL")
find_phi_register(${hip_src} ${pybind_file} "PD_REGISTER_STRUCT_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 "") if(NOT ${op_name} EQUAL "")
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n") file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${op_name}, CUDA);\n")
set(pybind_flag 1) set(pybind_flag 1)
......
...@@ -78,7 +78,7 @@ function(kernel_declare TARGET_LIST) ...@@ -78,7 +78,7 @@ function(kernel_declare TARGET_LIST)
string( string(
REGEX REGEX
MATCH 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 first_registry
"${kernel_impl}") "${kernel_impl}")
if(NOT first_registry STREQUAL "") if(NOT first_registry STREQUAL "")
...@@ -108,7 +108,7 @@ function(kernel_declare TARGET_LIST) ...@@ -108,7 +108,7 @@ function(kernel_declare TARGET_LIST)
string(REPLACE "PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(" "" kernel_msg string(REPLACE "PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(" "" kernel_msg
"${first_registry}") "${first_registry}")
string(REPLACE "PD_REGISTER_KERNEL(" "" kernel_msg "${kernel_msg}") 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}") "${kernel_msg}")
string(REPLACE "," ";" kernel_msg "${kernel_msg}") string(REPLACE "," ";" kernel_msg "${kernel_msg}")
string(REGEX REPLACE "[ \\\t\r\n]+" "" kernel_msg "${kernel_msg}") string(REGEX REPLACE "[ \\\t\r\n]+" "" kernel_msg "${kernel_msg}")
......
...@@ -212,77 +212,29 @@ REGISTER_OPERATOR( ...@@ -212,77 +212,29 @@ REGISTER_OPERATOR(
paddle::framework::EmptyGradOpMaker<paddle::imperative::OpBase>, paddle::framework::EmptyGradOpMaker<paddle::imperative::OpBase>,
paddle::operators::FeedOpInfoMaker); paddle::operators::FeedOpInfoMaker);
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_dense_tensor,
CPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_sparse_coo_tensor, feed_sparse_coo_tensor,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
paddle::operators::FeedSparseCooTensorKernel<phi::CPUContext>, paddle::operators::FeedSparseCooTensorKernel<phi::CPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
CPU,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::CPUContext>,
ALL_DTYPE) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_dense_tensor,
GPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_sparse_coo_tensor, feed_sparse_coo_tensor,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
paddle::operators::FeedSparseCooTensorKernel<phi::GPUContext>, paddle::operators::FeedSparseCooTensorKernel<phi::GPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
GPU,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::GPUContext>,
ALL_DTYPE) {}
#elif defined(PADDLE_WITH_XPU) #elif defined(PADDLE_WITH_XPU)
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_dense_tensor,
XPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::XPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_sparse_coo_tensor, feed_sparse_coo_tensor,
XPU, XPU,
ALL_LAYOUT, ALL_LAYOUT,
paddle::operators::FeedSparseCooTensorKernel<phi::XPUContext>, paddle::operators::FeedSparseCooTensorKernel<phi::XPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
XPU,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::XPUContext>,
ALL_DTYPE) {}
#endif
#ifdef PADDLE_WITH_CUSTOM_DEVICE
PD_REGISTER_GENERAL_KERNEL(
feed_dense_tensor,
Custom,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::CustomContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
Custom,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::CustomContext>,
ALL_DTYPE) {}
#endif #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) {
}
...@@ -1326,28 +1326,28 @@ struct KernelRegistrar { ...@@ -1326,28 +1326,28 @@ struct KernelRegistrar {
kernel_unfold_macro, \ kernel_unfold_macro, \
variadic_kernel_unfold_marco, \ variadic_kernel_unfold_marco, \
__VA_ARGS__)) __VA_ARGS__))
/** PD_REGISTER_GENERAL_KERNEL /** PD_REGISTER_KERNEL_FOR_ALL_DTYPE
* *
* Basic Kernel register marco, used to register a instantiated kernel function * Basic Kernel register marco, used to register a instantiated kernel function
* with one template argument. * with one template argument.
*/ */
#define PD_REGISTER_GENERAL_KERNEL( \ #define PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
kernel_name, backend, layout, kernel_fn, dtype) \ kernel_name, backend, layout, kernel_fn) \
_PD_REGISTER_GENERAL_KERNEL( \ _PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
::phi::RegType::INNER, kernel_name, backend, layout, kernel_fn, dtype) ::phi::RegType::INNER, kernel_name, backend, layout, kernel_fn)
#define _PD_REGISTER_GENERAL_KERNEL( \ #define _PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ reg_type, kernel_name, backend, layout, kernel_fn) \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \ PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_REGISTER_no_t_kernel_ns_check_##kernel_name##_##backend##_##layout, \ PD_REGISTER_no_t_kernel_ns_check_##kernel_name##_##backend##_##layout, \
"PD_REGISTER_NO_TEMPLATE_KERNEL must be called in global namespace."); \ "PD_REGISTER_NO_TEMPLATE_KERNEL must be called in global namespace."); \
__PD_REGISTER_GENERAL_KERNEL( \ __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
reg_type, kernel_name, backend, layout, kernel_fn, dtype) reg_type, kernel_name, backend, layout, kernel_fn)
#ifndef _WIN32 #ifndef _WIN32
#define __PD_REGISTER_GENERAL_KERNEL( \ #define __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ reg_type, kernel_name, backend, layout, kernel_fn) \
template decltype(kernel_fn) kernel_fn; \ template decltype(kernel_fn) kernel_fn; \
static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \
const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \ const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \
...@@ -1367,8 +1367,8 @@ struct KernelRegistrar { ...@@ -1367,8 +1367,8 @@ struct KernelRegistrar {
void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \
const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel) const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel)
#else #else
#define __PD_REGISTER_GENERAL_KERNEL( \ #define __PD_REGISTER_KERNEL_FOR_ALL_DTYPE( \
reg_type, kernel_name, backend, layout, kernel_fn, dtype) \ reg_type, kernel_name, backend, layout, kernel_fn) \
static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ static void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \
const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \ const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel); \
static const ::phi::KernelRegistrar \ static const ::phi::KernelRegistrar \
......
...@@ -108,21 +108,21 @@ void AssignValueKernel(const Context& dev_ctx, ...@@ -108,21 +108,21 @@ void AssignValueKernel(const Context& dev_ctx,
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
assign, CPU, ALL_LAYOUT, phi::AssignKernel<phi::CPUContext>, ALL_DTYPE) {} CPU,
ALL_LAYOUT,
phi::AssignKernel<phi::CPUContext>) {}
PD_REGISTER_GENERAL_KERNEL(assign_raw, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::AssignRawKernel<phi::CPUContext>, phi::AssignRawKernel<phi::CPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_GENERAL_KERNEL(assign_array, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::AssignArrayKernel<phi::CPUContext>, phi::AssignArrayKernel<phi::CPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_KERNEL(assign_value, PD_REGISTER_KERNEL(assign_value,
...@@ -135,20 +135,20 @@ PD_REGISTER_KERNEL(assign_value, ...@@ -135,20 +135,20 @@ PD_REGISTER_KERNEL(assign_value,
int64_t) {} int64_t) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
assign, GPU, ALL_LAYOUT, phi::AssignKernel<phi::GPUContext>, ALL_DTYPE) {} GPU,
PD_REGISTER_GENERAL_KERNEL(assign_raw, ALL_LAYOUT,
GPU, phi::AssignKernel<phi::GPUContext>) {}
ALL_LAYOUT, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
phi::AssignRawKernel<phi::GPUContext>, GPU,
ALL_DTYPE) { ALL_LAYOUT,
phi::AssignRawKernel<phi::GPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_GENERAL_KERNEL(assign_array, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::AssignArrayKernel<phi::GPUContext>, phi::AssignArrayKernel<phi::GPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_KERNEL(assign_value, PD_REGISTER_KERNEL(assign_value,
...@@ -162,20 +162,20 @@ PD_REGISTER_KERNEL(assign_value, ...@@ -162,20 +162,20 @@ PD_REGISTER_KERNEL(assign_value,
#endif #endif
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
assign, XPU, ALL_LAYOUT, phi::AssignKernel<phi::XPUContext>, ALL_DTYPE) {} XPU,
PD_REGISTER_GENERAL_KERNEL(assign_raw, ALL_LAYOUT,
XPU, phi::AssignKernel<phi::XPUContext>) {}
ALL_LAYOUT, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
phi::AssignRawKernel<phi::XPUContext>, XPU,
ALL_DTYPE) { ALL_LAYOUT,
phi::AssignRawKernel<phi::XPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_GENERAL_KERNEL(assign_array, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
XPU, XPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::AssignArrayKernel<phi::XPUContext>, phi::AssignArrayKernel<phi::XPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
PD_REGISTER_KERNEL(assign_value, PD_REGISTER_KERNEL(assign_value,
......
...@@ -136,83 +136,78 @@ void MemcpyKernel(const Context& dev_ctx, ...@@ -136,83 +136,78 @@ void MemcpyKernel(const Context& dev_ctx,
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::CPUContext>, phi::MemcpyH2DKernel<phi::CPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, CPU,
CPU, ALL_LAYOUT,
ALL_LAYOUT, phi::MemcpyD2HKernel<phi::CPUContext>) {
phi::MemcpyD2HKernel<phi::CPUContext>,
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::CPUContext>, phi::MemcpyD2HMultiIOKernel<phi::CPUContext>) {
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy,
memcpy, CPU, ALL_LAYOUT, phi::MemcpyKernel<phi::CPUContext>, ALL_DTYPE) { CPU,
ALL_LAYOUT,
phi::MemcpyKernel<phi::CPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::GPUContext>, phi::MemcpyH2DKernel<phi::GPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, GPU,
GPU, ALL_LAYOUT,
ALL_LAYOUT, phi::MemcpyD2HKernel<phi::GPUContext>) {
phi::MemcpyD2HKernel<phi::GPUContext>,
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::GPUContext>, phi::MemcpyD2HMultiIOKernel<phi::GPUContext>) {
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
PD_REGISTER_GENERAL_KERNEL( PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy,
memcpy, GPU, ALL_LAYOUT, phi::MemcpyKernel<phi::GPUContext>, ALL_DTYPE) { GPU,
ALL_LAYOUT,
phi::MemcpyKernel<phi::GPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
#endif #endif
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL(memcpy_h2d, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
XPU, XPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::XPUContext>, phi::MemcpyH2DKernel<phi::XPUContext>) {}
ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h, XPU,
XPU, ALL_LAYOUT,
ALL_LAYOUT, phi::MemcpyD2HKernel<phi::XPUContext>) {
phi::MemcpyD2HKernel<phi::XPUContext>,
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
XPU, XPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::XPUContext>, phi::MemcpyD2HMultiIOKernel<phi::XPUContext>) {
ALL_DTYPE) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU); kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
} }
......
...@@ -61,52 +61,9 @@ void ReshapeDoubleGradKernel(const Context& dev_ctx, ...@@ -61,52 +61,9 @@ void ReshapeDoubleGradKernel(const Context& dev_ctx,
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(reshape_grad, PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(reshape_grad,
CPU, ALL_LAYOUT,
ALL_LAYOUT, phi::ReshapeGradKernel) {}
phi::ReshapeGradKernel<phi::CPUContext>, PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(reshape_double_grad,
ALL_DTYPE) {} ALL_LAYOUT,
PD_REGISTER_GENERAL_KERNEL(reshape_double_grad, phi::ReshapeDoubleGradKernel) {}
CPU,
ALL_LAYOUT,
phi::ReshapeDoubleGradKernel<phi::CPUContext>,
ALL_DTYPE) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(reshape_grad,
GPU,
ALL_LAYOUT,
phi::ReshapeGradKernel<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(reshape_double_grad,
GPU,
ALL_LAYOUT,
phi::ReshapeDoubleGradKernel<phi::GPUContext>,
ALL_DTYPE) {}
#endif
#ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL(reshape_grad,
XPU,
ALL_LAYOUT,
phi::ReshapeGradKernel<phi::XPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(reshape_double_grad,
XPU,
ALL_LAYOUT,
phi::ReshapeDoubleGradKernel<phi::XPUContext>,
ALL_DTYPE) {}
#endif
#ifdef PADDLE_WITH_CUSTOM_DEVICE
PD_REGISTER_GENERAL_KERNEL(reshape_grad,
Custom,
ALL_LAYOUT,
phi::ReshapeGradKernel<phi::CustomContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(reshape_double_grad,
Custom,
ALL_LAYOUT,
phi::ReshapeDoubleGradKernel<phi::CustomContext>,
ALL_DTYPE) {}
#endif
...@@ -34,30 +34,27 @@ void AssignKernel(const Context& dev_ctx, ...@@ -34,30 +34,27 @@ void AssignKernel(const Context& dev_ctx,
} // namespace sr } // namespace sr
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(assign_sr, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::sr::AssignKernel<phi::CPUContext>, phi::sr::AssignKernel<phi::CPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(assign_sr, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::sr::AssignKernel<phi::GPUContext>, phi::sr::AssignKernel<phi::GPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
#endif #endif
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL(assign_sr, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
XPU, XPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::sr::AssignKernel<phi::XPUContext>, phi::sr::AssignKernel<phi::XPUContext>) {
ALL_DTYPE) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
} }
#endif #endif
...@@ -46,24 +46,6 @@ void ShareBufferKernel(const Context &dev_ctx, ...@@ -46,24 +46,6 @@ void ShareBufferKernel(const Context &dev_ctx,
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(share_buffer, PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(share_buffer,
CPU, ALL_LAYOUT,
ALL_LAYOUT, phi::ShareBufferKernel) {}
phi::ShareBufferKernel<phi::CPUContext>,
ALL_DTYPE) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(share_buffer,
GPU,
ALL_LAYOUT,
phi::ShareBufferKernel<phi::GPUContext>,
ALL_DTYPE) {}
#endif
#ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL(share_buffer,
XPU,
ALL_LAYOUT,
phi::ShareBufferKernel<phi::XPUContext>,
ALL_DTYPE) {}
#endif
...@@ -53,8 +53,7 @@ void Copy(const Context& dev_ctx, ...@@ -53,8 +53,7 @@ void Copy(const Context& dev_ctx,
} // namespace strings } // namespace strings
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(strings_copy, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::strings::Copy<phi::CPUContext>, phi::strings::Copy<phi::CPUContext>) {}
pstring) {}
...@@ -43,14 +43,14 @@ void StringUpperKernel(const ContextT& dev_ctx, ...@@ -43,14 +43,14 @@ void StringUpperKernel(const ContextT& dev_ctx,
} // namespace strings } // namespace strings
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(strings_lower, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
CPU, strings_lower,
ALL_LAYOUT, CPU,
phi::strings::StringLowerKernel<phi::CPUContext>, ALL_LAYOUT,
pstring) {} phi::strings::StringLowerKernel<phi::CPUContext>) {}
PD_REGISTER_GENERAL_KERNEL(strings_upper, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
CPU, strings_upper,
ALL_LAYOUT, CPU,
phi::strings::StringUpperKernel<phi::CPUContext>, ALL_LAYOUT,
pstring) {} phi::strings::StringUpperKernel<phi::CPUContext>) {}
...@@ -120,8 +120,7 @@ void Copy(const Context& dev_ctx, ...@@ -120,8 +120,7 @@ void Copy(const Context& dev_ctx,
} // namespace strings } // namespace strings
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(strings_copy, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::strings::Copy<phi::GPUContext>, phi::strings::Copy<phi::GPUContext>) {}
pstring) {}
...@@ -167,14 +167,14 @@ void StringUpperKernel(const ContextT& dev_ctx, ...@@ -167,14 +167,14 @@ void StringUpperKernel(const ContextT& dev_ctx,
} // namespace strings } // namespace strings
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(strings_lower, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
GPU, strings_lower,
ALL_LAYOUT, GPU,
phi::strings::StringLowerKernel<phi::GPUContext>, ALL_LAYOUT,
pstring) {} phi::strings::StringLowerKernel<phi::GPUContext>) {}
PD_REGISTER_GENERAL_KERNEL(strings_upper, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
GPU, strings_upper,
ALL_LAYOUT, GPU,
phi::strings::StringUpperKernel<phi::GPUContext>, ALL_LAYOUT,
pstring) {} phi::strings::StringUpperKernel<phi::GPUContext>) {}
...@@ -38,28 +38,26 @@ void EmptyLikeKernel(const Context& dev_ctx, StringTensor* out) { ...@@ -38,28 +38,26 @@ void EmptyLikeKernel(const Context& dev_ctx, StringTensor* out) {
using pstring = ::phi::dtype::pstring; using pstring = ::phi::dtype::pstring;
PD_REGISTER_GENERAL_KERNEL(strings_empty, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::strings::EmptyKernel<phi::CPUContext>, phi::strings::EmptyKernel<phi::CPUContext>) {}
pstring) {}
PD_REGISTER_GENERAL_KERNEL(strings_empty_like, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
CPU, strings_empty_like,
ALL_LAYOUT, CPU,
phi::strings::EmptyLikeKernel<phi::CPUContext>, ALL_LAYOUT,
pstring) {} phi::strings::EmptyLikeKernel<phi::CPUContext>) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(strings_empty, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::strings::EmptyKernel<phi::GPUContext>, phi::strings::EmptyKernel<phi::GPUContext>) {}
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
PD_REGISTER_GENERAL_KERNEL(strings_empty_like, strings_empty_like,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::strings::EmptyLikeKernel<phi::GPUContext>, phi::strings::EmptyLikeKernel<phi::GPUContext>) {}
pstring) {}
#endif #endif
...@@ -202,15 +202,13 @@ void TransferLayoutKernel(const Context& dev_ctx, ...@@ -202,15 +202,13 @@ void TransferLayoutKernel(const Context& dev_ctx,
} // namespace phi } // namespace phi
PD_REGISTER_GENERAL_KERNEL(transfer_layout, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout,
CPU, CPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::TransferLayoutKernel<phi::CPUContext>, phi::TransferLayoutKernel<phi::CPUContext>) {}
ALL_DTYPE) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(transfer_layout, PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout,
GPU, GPU,
ALL_LAYOUT, ALL_LAYOUT,
phi::TransferLayoutKernel<phi::GPUContext>, phi::TransferLayoutKernel<phi::GPUContext>) {}
ALL_DTYPE) {}
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册