未验证 提交 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)
# 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)
......
......@@ -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}")
......
......@@ -212,77 +212,29 @@ REGISTER_OPERATOR(
paddle::framework::EmptyGradOpMaker<paddle::imperative::OpBase>,
paddle::operators::FeedOpInfoMaker);
PD_REGISTER_GENERAL_KERNEL(
feed_dense_tensor,
CPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_sparse_coo_tensor,
CPU,
ALL_LAYOUT,
paddle::operators::FeedSparseCooTensorKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
CPU,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::CPUContext>,
ALL_DTYPE) {}
paddle::operators::FeedSparseCooTensorKernel<phi::CPUContext>) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(
feed_dense_tensor,
GPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_sparse_coo_tensor,
GPU,
ALL_LAYOUT,
paddle::operators::FeedSparseCooTensorKernel<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
feed_strings,
GPU,
ALL_LAYOUT,
paddle::operators::FeedStringsKernel<phi::GPUContext>,
ALL_DTYPE) {}
paddle::operators::FeedSparseCooTensorKernel<phi::GPUContext>) {}
#elif defined(PADDLE_WITH_XPU)
PD_REGISTER_GENERAL_KERNEL(
feed_dense_tensor,
XPU,
ALL_LAYOUT,
paddle::operators::FeedDenseTensorKernel<phi::XPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
feed_sparse_coo_tensor,
XPU,
ALL_LAYOUT,
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) {}
paddle::operators::FeedSparseCooTensorKernel<phi::XPUContext>) {}
#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 {
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 \
......
......@@ -108,21 +108,21 @@ void AssignValueKernel(const Context& dev_ctx,
} // namespace phi
PD_REGISTER_GENERAL_KERNEL(
assign, CPU, ALL_LAYOUT, phi::AssignKernel<phi::CPUContext>, ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
CPU,
ALL_LAYOUT,
phi::AssignKernel<phi::CPUContext>) {}
PD_REGISTER_GENERAL_KERNEL(assign_raw,
CPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::CPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
CPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::CPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
PD_REGISTER_GENERAL_KERNEL(assign_array,
CPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::CPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
CPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::CPUContext>) {
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<phi::GPUContext>, ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(assign_raw,
GPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::GPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
GPU,
ALL_LAYOUT,
phi::AssignKernel<phi::GPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
GPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::GPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
PD_REGISTER_GENERAL_KERNEL(assign_array,
GPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::GPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
GPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::GPUContext>) {
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<phi::XPUContext>, ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(assign_raw,
XPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::XPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign,
XPU,
ALL_LAYOUT,
phi::AssignKernel<phi::XPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_raw,
XPU,
ALL_LAYOUT,
phi::AssignRawKernel<phi::XPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
PD_REGISTER_GENERAL_KERNEL(assign_array,
XPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::XPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_array,
XPU,
ALL_LAYOUT,
phi::AssignArrayKernel<phi::XPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
PD_REGISTER_KERNEL(assign_value,
......
......@@ -136,83 +136,78 @@ void MemcpyKernel(const Context& dev_ctx,
} // namespace phi
PD_REGISTER_GENERAL_KERNEL(memcpy_h2d,
CPU,
ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h,
CPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::CPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
CPU,
ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::CPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
CPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::CPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io,
CPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::CPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
CPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::CPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
PD_REGISTER_GENERAL_KERNEL(
memcpy, CPU, ALL_LAYOUT, phi::MemcpyKernel<phi::CPUContext>, ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy,
CPU,
ALL_LAYOUT,
phi::MemcpyKernel<phi::CPUContext>) {
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<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h,
GPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::GPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
GPU,
ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::GPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
GPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::GPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io,
GPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::GPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
GPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::GPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
PD_REGISTER_GENERAL_KERNEL(
memcpy, GPU, ALL_LAYOUT, phi::MemcpyKernel<phi::GPUContext>, ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy,
GPU,
ALL_LAYOUT,
phi::MemcpyKernel<phi::GPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
#endif
#ifdef PADDLE_WITH_XPU
PD_REGISTER_GENERAL_KERNEL(memcpy_h2d,
XPU,
ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::XPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h,
XPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::XPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_h2d,
XPU,
ALL_LAYOUT,
phi::MemcpyH2DKernel<phi::XPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h,
XPU,
ALL_LAYOUT,
phi::MemcpyD2HKernel<phi::XPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
PD_REGISTER_GENERAL_KERNEL(memcpy_d2h_multi_io,
XPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::XPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(memcpy_d2h_multi_io,
XPU,
ALL_LAYOUT,
phi::MemcpyD2HMultiIOKernel<phi::XPUContext>) {
kernel->OutputAt(0).SetBackend(phi::Backend::CPU);
}
......
......@@ -61,52 +61,9 @@ void ReshapeDoubleGradKernel(const Context& dev_ctx,
} // namespace phi
PD_REGISTER_GENERAL_KERNEL(reshape_grad,
CPU,
ALL_LAYOUT,
phi::ReshapeGradKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_GENERAL_KERNEL(reshape_double_grad,
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
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) {}
......@@ -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<phi::CPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
CPU,
ALL_LAYOUT,
phi::sr::AssignKernel<phi::CPUContext>) {
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<phi::GPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
GPU,
ALL_LAYOUT,
phi::sr::AssignKernel<phi::GPUContext>) {
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<phi::XPUContext>,
ALL_DTYPE) {
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(assign_sr,
XPU,
ALL_LAYOUT,
phi::sr::AssignKernel<phi::XPUContext>) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
}
#endif
......@@ -46,24 +46,6 @@ void ShareBufferKernel(const Context &dev_ctx,
} // namespace phi
PD_REGISTER_GENERAL_KERNEL(share_buffer,
CPU,
ALL_LAYOUT,
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
PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE(share_buffer,
ALL_LAYOUT,
phi::ShareBufferKernel) {}
......@@ -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<phi::CPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy,
CPU,
ALL_LAYOUT,
phi::strings::Copy<phi::CPUContext>) {}
......@@ -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<phi::CPUContext>,
pstring) {}
PD_REGISTER_GENERAL_KERNEL(strings_upper,
CPU,
ALL_LAYOUT,
phi::strings::StringUpperKernel<phi::CPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_lower,
CPU,
ALL_LAYOUT,
phi::strings::StringLowerKernel<phi::CPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_upper,
CPU,
ALL_LAYOUT,
phi::strings::StringUpperKernel<phi::CPUContext>) {}
......@@ -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<phi::GPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_copy,
GPU,
ALL_LAYOUT,
phi::strings::Copy<phi::GPUContext>) {}
......@@ -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<phi::GPUContext>,
pstring) {}
PD_REGISTER_GENERAL_KERNEL(strings_upper,
GPU,
ALL_LAYOUT,
phi::strings::StringUpperKernel<phi::GPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_lower,
GPU,
ALL_LAYOUT,
phi::strings::StringLowerKernel<phi::GPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_upper,
GPU,
ALL_LAYOUT,
phi::strings::StringUpperKernel<phi::GPUContext>) {}
......@@ -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<phi::CPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty,
CPU,
ALL_LAYOUT,
phi::strings::EmptyKernel<phi::CPUContext>) {}
PD_REGISTER_GENERAL_KERNEL(strings_empty_like,
CPU,
ALL_LAYOUT,
phi::strings::EmptyLikeKernel<phi::CPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_empty_like,
CPU,
ALL_LAYOUT,
phi::strings::EmptyLikeKernel<phi::CPUContext>) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(strings_empty,
GPU,
ALL_LAYOUT,
phi::strings::EmptyKernel<phi::GPUContext>,
pstring) {}
PD_REGISTER_GENERAL_KERNEL(strings_empty_like,
GPU,
ALL_LAYOUT,
phi::strings::EmptyLikeKernel<phi::GPUContext>,
pstring) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(strings_empty,
GPU,
ALL_LAYOUT,
phi::strings::EmptyKernel<phi::GPUContext>) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(
strings_empty_like,
GPU,
ALL_LAYOUT,
phi::strings::EmptyLikeKernel<phi::GPUContext>) {}
#endif
......@@ -202,15 +202,13 @@ void TransferLayoutKernel(const Context& dev_ctx,
} // namespace phi
PD_REGISTER_GENERAL_KERNEL(transfer_layout,
CPU,
ALL_LAYOUT,
phi::TransferLayoutKernel<phi::CPUContext>,
ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout,
CPU,
ALL_LAYOUT,
phi::TransferLayoutKernel<phi::CPUContext>) {}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_GENERAL_KERNEL(transfer_layout,
GPU,
ALL_LAYOUT,
phi::TransferLayoutKernel<phi::GPUContext>,
ALL_DTYPE) {}
PD_REGISTER_KERNEL_FOR_ALL_DTYPE(transfer_layout,
GPU,
ALL_LAYOUT,
phi::TransferLayoutKernel<phi::GPUContext>) {}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册