diff --git a/paddle/phi/kernels/stride/as_strided_kernel.cc b/paddle/phi/kernels/stride/as_strided_kernel.cc index 0cd63577d1e96..28ea8f4e63842 100644 --- a/paddle/phi/kernels/stride/as_strided_kernel.cc +++ b/paddle/phi/kernels/stride/as_strided_kernel.cc @@ -24,9 +24,11 @@ void AsStridedKernel(const Context& dev_ctx, const std::vector& stride, int64_t offset, DenseTensor* out) { - out->Resize(DDim(dims.data(), static_cast(dims.size()))); - out->set_strides(DDim(stride.data(), static_cast(stride.size()))); - out->set_offset(offset); + auto meta = out->meta(); + meta.dims = DDim(dims.data(), static_cast(dims.size())); + meta.strides = DDim(stride.data(), static_cast(stride.size())); + meta.offset = offset; + out->set_meta(meta); out->ResetHolder(input.Holder()); out->ShareInplaceVersionCounterWith(input); } diff --git a/paddle/phi/kernels/stride/tensor_unfold_kernel.cc b/paddle/phi/kernels/stride/tensor_unfold_kernel.cc index 0a4d4ee9af3e2..79643ac3dc514 100644 --- a/paddle/phi/kernels/stride/tensor_unfold_kernel.cc +++ b/paddle/phi/kernels/stride/tensor_unfold_kernel.cc @@ -61,9 +61,11 @@ void TensorUnfoldKernel(const Context& dev_ctx, } } - out->Resize(DDim(shape.data(), static_cast(shape.size()))); - out->set_strides(DDim(stride.data(), static_cast(stride.size()))); - out->set_offset(input.offset()); + auto meta = out->meta(); + meta.dims = DDim(shape.data(), static_cast(shape.size())); + meta.strides = DDim(stride.data(), static_cast(stride.size())); + meta.offset = input.offset(); + out->set_meta(meta); out->ResetHolder(input.Holder()); out->ShareInplaceVersionCounterWith(input); }