diff --git a/paddle/phi/kernels/shape_kernel.cc b/paddle/phi/kernels/shape_kernel.cc index f35b7e544476e10617bab2cdec6d170d38d8770e..d4dbdbaf178b0594d406537def975178095d6042 100644 --- a/paddle/phi/kernels/shape_kernel.cc +++ b/paddle/phi/kernels/shape_kernel.cc @@ -23,12 +23,9 @@ template void ShapeKernel(const Context& ctx, const DenseTensor& input, DenseTensor* out) { - auto in_var = &input; - phi::DDim in_dims; - in_dims = in_var->dims(); - auto out_t = out; - out_t->Resize({in_dims.size()}); - auto out_data = ctx.template HostAlloc(out_t); + auto& in_dims = input.dims(); + out->Resize({in_dims.size()}); + auto out_data = ctx.template HostAlloc(out); for (int i = 0; i < in_dims.size(); ++i) { out_data[i] = in_dims[i]; }