From de49a4b7534682bff8a34767cae11135d5361837 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Tue, 12 Apr 2022 14:39:14 +0800 Subject: [PATCH] exchange assign and assign_raw kernel name (#41625) * exchange assign and assign_raw kernel name * fix register error --- paddle/phi/kernels/assign_kernel.cc | 28 +++++++++++----------- paddle/phi/kernels/assign_kernel.h | 12 +++++----- paddle/phi/ops/compat/assign_sig.cc | 4 ++-- python/paddle/utils/code_gen/api.yaml | 2 +- python/paddle/utils/code_gen/backward.yaml | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/paddle/phi/kernels/assign_kernel.cc b/paddle/phi/kernels/assign_kernel.cc index 5eafc869fa..720ebb5b78 100644 --- a/paddle/phi/kernels/assign_kernel.cc +++ b/paddle/phi/kernels/assign_kernel.cc @@ -23,22 +23,22 @@ namespace phi { template -void AssignRawKernel(const Context& dev_ctx, - const DenseTensor& x, - DenseTensor* out) { +void AssignKernel(const Context& dev_ctx, + const DenseTensor& x, + DenseTensor* out) { Copy(dev_ctx, x, x.place(), false, out); } template -void AssignKernel(const Context& dev_ctx, - paddle::optional x, - DenseTensor* out) { +void AssignRawKernel(const Context& dev_ctx, + paddle::optional x, + DenseTensor* out) { if (x) { if (!x->IsInitialized()) { return; } auto& x_tensor = *x.get_ptr(); - AssignRawKernel(dev_ctx, x_tensor, out); + AssignKernel(dev_ctx, x_tensor, out); } } @@ -111,14 +111,14 @@ void AssignValueKernel(const Context& dev_ctx, } // namespace phi +PD_REGISTER_GENERAL_KERNEL( + assign, CPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) {} + PD_REGISTER_GENERAL_KERNEL(assign_raw, CPU, ALL_LAYOUT, phi::AssignRawKernel, - ALL_DTYPE) {} - -PD_REGISTER_GENERAL_KERNEL( - assign, CPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) { + ALL_DTYPE) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } PD_REGISTER_GENERAL_KERNEL(assign_array, @@ -136,13 +136,13 @@ 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_GENERAL_KERNEL( - assign, GPU, ALL_LAYOUT, phi::AssignKernel, ALL_DTYPE) { + ALL_DTYPE) { kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); } PD_REGISTER_GENERAL_KERNEL(assign_array, diff --git a/paddle/phi/kernels/assign_kernel.h b/paddle/phi/kernels/assign_kernel.h index 437a2a0c18..6881ac9f0e 100644 --- a/paddle/phi/kernels/assign_kernel.h +++ b/paddle/phi/kernels/assign_kernel.h @@ -22,17 +22,17 @@ namespace phi { template -void AssignRawKernel(const Context& dev_ctx, - const DenseTensor& x, - DenseTensor* out); +void AssignKernel(const Context& dev_ctx, + const DenseTensor& x, + DenseTensor* out); // In order to be compatible with the `AsDispensable` input in the original // assign op maker, the input parameter here needs to be dispensable, but // this looks weird template -void AssignKernel(const Context& dev_ctx, - paddle::optional x, - DenseTensor* out); +void AssignRawKernel(const Context& dev_ctx, + paddle::optional x, + DenseTensor* out); template void AssignArrayKernel(const Context& dev_ctx, diff --git a/paddle/phi/ops/compat/assign_sig.cc b/paddle/phi/ops/compat/assign_sig.cc index d149e8e6a9..c8cd9e44ff 100644 --- a/paddle/phi/ops/compat/assign_sig.cc +++ b/paddle/phi/ops/compat/assign_sig.cc @@ -23,10 +23,10 @@ KernelSignature AssignOpArgumentMapping(const ArgumentMappingContext& ctx) { } else if (ctx.IsSelectedRowsInput("X")) { return KernelSignature("assign_sr", {"X"}, {}, {"Out"}); } else { - return KernelSignature("assign", {"X"}, {}, {"Out"}); + return KernelSignature("assign_raw", {"X"}, {}, {"Out"}); } } else { - return KernelSignature("assign", {"X"}, {}, {"Out"}); + return KernelSignature("assign_raw", {"X"}, {}, {"Out"}); } } diff --git a/python/paddle/utils/code_gen/api.yaml b/python/paddle/utils/code_gen/api.yaml index 7e6740b6cb..b20259d3eb 100644 --- a/python/paddle/utils/code_gen/api.yaml +++ b/python/paddle/utils/code_gen/api.yaml @@ -174,7 +174,7 @@ infer_meta : func : UnchangedInferMeta kernel : - func : assign_raw + func : assign backward : assign_grad # atan diff --git a/python/paddle/utils/code_gen/backward.yaml b/python/paddle/utils/code_gen/backward.yaml index e2c5a970af..78f4ac7c98 100644 --- a/python/paddle/utils/code_gen/backward.yaml +++ b/python/paddle/utils/code_gen/backward.yaml @@ -120,7 +120,7 @@ func : UnchangedInferMeta param : [out_grad] kernel : - func : assign_raw + func : assign - backward_api : atan2_grad forward : atan2 (Tensor x, Tensor y) -> Tensor(out) -- GitLab