From acad2717347d89c8e565703d9ebf5f013111d362 Mon Sep 17 00:00:00 2001 From: tianhaodongbd <137985359+tianhaodongbd@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:59:35 +0800 Subject: [PATCH] optimized expand_as_kernel (#57509) --- paddle/phi/kernels/gpu/expand_as_kernel.cu | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/paddle/phi/kernels/gpu/expand_as_kernel.cu b/paddle/phi/kernels/gpu/expand_as_kernel.cu index 603e43482b929..b296b5b7e2014 100644 --- a/paddle/phi/kernels/gpu/expand_as_kernel.cu +++ b/paddle/phi/kernels/gpu/expand_as_kernel.cu @@ -18,6 +18,7 @@ #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/expand_kernel.h" #include "paddle/phi/kernels/funcs/broadcast_function.h" namespace phi { @@ -70,11 +71,7 @@ void ExpandAsKernel(const Context& ctx, } } - out->Resize(phi::make_ddim(target_shape)); - ctx.template Alloc(out); - std::vector ins = {&x}; - std::vector outs = {out}; - phi::funcs::BroadcastKernel(ctx, ins, &outs, kps::IdentityFunctor()); + ExpandKernel(ctx, x, target_shape, out); } } // namespace phi