diff --git a/paddle/phi/kernels/xpu/expand_as_kernel.cc b/paddle/phi/kernels/xpu/expand_as_kernel.cc index 3ff46d64e96b782a66b9e7dc94eaced6bb388fe1..1427c61f4503b3f6d7d5e8f35d77d6e4d711ce7a 100644 --- a/paddle/phi/kernels/xpu/expand_as_kernel.cc +++ b/paddle/phi/kernels/xpu/expand_as_kernel.cc @@ -23,11 +23,11 @@ namespace phi { template void ExpandAs(const Context& context, - const DenseTensor& in0, + const DenseTensor& x, const std::vector& target_shape, - DenseTensor* out0) { + DenseTensor* out) { using XPUType = typename XPUTypeTrait::Type; - auto in_dims = in0.dims(); + auto in_dims = x.dims(); auto vec_in_dims = phi::vectorize(in_dims); auto diff = target_shape.size() - vec_in_dims.size(); vec_in_dims.insert(vec_in_dims.begin(), diff, 1); @@ -50,23 +50,23 @@ void ExpandAs(const Context& context, } } phi::DDim out_dims = phi::make_ddim(target_shape); - out0->Resize(out_dims); - context.template Alloc(out0); - auto& in0_shape = vec_in_dims; - auto out0_shape = phi::vectorize(out_dims); + out->Resize(out_dims); + context.template Alloc(out); + auto& x_shape = vec_in_dims; + auto out_shape = phi::vectorize(out_dims); int r = XPU_SUCCESS; if (std::is_same::value) { - auto in0_data = reinterpret_cast(in0.data()); - auto out0_data = reinterpret_cast(out0->data()); + auto x_data = reinterpret_cast(x.data()); + auto out_data = reinterpret_cast(out->data()); r = xpu::broadcast( - context.x_context(), in0_data, out0_data, in0_shape, out0_shape); + context.x_context(), x_data, out_data, x_shape, out_shape); } else { - auto in0_data = reinterpret_cast(in0.data()); - auto out0_data = reinterpret_cast(out0->data()); + auto x_data = reinterpret_cast(x.data()); + auto out_data = reinterpret_cast(out->data()); r = xpu::broadcast( - context.x_context(), in0_data, out0_data, in0_shape, out0_shape); + context.x_context(), x_data, out_data, x_shape, out_shape); } PADDLE_ENFORCE_EQ( r,