From 4e19ce1df5b8f592f2d1acb65aa694a3b49f0d8b Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Mon, 7 Dec 2020 19:27:57 +0800 Subject: [PATCH] refine reshape grad and double grad kernel, use tensor copy async (#29128) --- paddle/fluid/operators/reshape_op.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/reshape_op.cc b/paddle/fluid/operators/reshape_op.cc index 1a0a8581184..7b93ea15de3 100644 --- a/paddle/fluid/operators/reshape_op.cc +++ b/paddle/fluid/operators/reshape_op.cc @@ -405,7 +405,9 @@ class ReshapeGradKernel { auto in_dims = d_x->dims(); d_x->mutable_data(ctx.GetPlace(), d_out->type()); - framework::TensorCopySync(*d_out, ctx.GetPlace(), d_x); + framework::TensorCopy( + *d_out, ctx.GetPlace(), + ctx.template device_context(), d_x); d_x->Resize(in_dims); } }; @@ -419,7 +421,9 @@ class ReshapeDoubleGradKernel { auto out_dims = dd_out->dims(); dd_out->mutable_data(ctx.GetPlace(), dd_x->type()); - framework::TensorCopySync(*dd_x, ctx.GetPlace(), dd_out); + framework::TensorCopy( + *dd_x, ctx.GetPlace(), + ctx.template device_context(), dd_out); dd_out->Resize(out_dims); } }; -- GitLab