From 08ee7485c990c399d280620f05e866e8332ab5de Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Tue, 8 Dec 2020 10:31:16 +0800 Subject: [PATCH] refine reshape grad and double grad kernel, use tensor copy async (#29128) (#29446) --- 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