Skip to content

Commit

Permalink
fix stride reshape inplace bug (PaddlePaddle#57353)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuancoder authored and zhuyipin committed Nov 13, 2023
1 parent f3645ac commit 42bbd17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions paddle/phi/kernels/stride/reshape_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ void ReshapeStridedKernel(const Context& dev_ctx,
out->ResetHolder(x.Holder());
} else {
DenseTensor tmp;
tmp.set_meta(x.meta());
DenseTensor tmp_x = x;
tmp_x.Resize(x_dims);
tmp_x.set_strides(x_stride);
tmp.set_meta(tmp_x.meta());
PD_VISIT_ALL_TYPES(x.dtype(), "ReshapeStridedKernel", ([&] {
phi::ContiguousKernel<data_t, Context>(
dev_ctx, x, &tmp);
dev_ctx, tmp_x, &tmp);
}));
out->set_strides(DenseTensorMeta::calc_strides(out->dims()));
out->set_offset(0);
Expand Down

0 comments on commit 42bbd17

Please sign in to comment.