Skip to content

Commit 08ee748

Browse files
authored
refine reshape grad and double grad kernel, use tensor copy async (#29128) (#29446)
1 parent 14cf420 commit 08ee748

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

paddle/fluid/operators/reshape_op.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ class ReshapeGradKernel {
405405
auto in_dims = d_x->dims();
406406

407407
d_x->mutable_data(ctx.GetPlace(), d_out->type());
408-
framework::TensorCopySync(*d_out, ctx.GetPlace(), d_x);
408+
framework::TensorCopy(
409+
*d_out, ctx.GetPlace(),
410+
ctx.template device_context<platform::DeviceContext>(), d_x);
409411
d_x->Resize(in_dims);
410412
}
411413
};
@@ -419,7 +421,9 @@ class ReshapeDoubleGradKernel {
419421
auto out_dims = dd_out->dims();
420422

421423
dd_out->mutable_data(ctx.GetPlace(), dd_x->type());
422-
framework::TensorCopySync(*dd_x, ctx.GetPlace(), dd_out);
424+
framework::TensorCopy(
425+
*dd_x, ctx.GetPlace(),
426+
ctx.template device_context<platform::DeviceContext>(), dd_out);
423427
dd_out->Resize(out_dims);
424428
}
425429
};

0 commit comments

Comments
 (0)