diff --git a/paddle/fluid/operators/matmul_v2_op_npu.cc b/paddle/fluid/operators/matmul_v2_op_npu.cc index 5ec48d3bf05454da6dec8d383f87faffa774baaf..3d77c177500e384e0fa344a70b93ae2ae7582b56 100644 --- a/paddle/fluid/operators/matmul_v2_op_npu.cc +++ b/paddle/fluid/operators/matmul_v2_op_npu.cc @@ -141,17 +141,13 @@ class MatMulV2GradNPUKernel : public framework::OpKernel { if ((x->dims().size() == 3) && (dout->dims().size() == 3) && (dy->dims().size() == 2)) { framework::Tensor dout_; - TensorCopy(*dout, ctx.GetPlace(), &dout_); - ctx.template device_context() - .Wait(); + dout_.ShareDataWith(*dout); std::vector vec_dim = framework::vectorize(dout_.dims()); std::vector vec_dim_v{vec_dim[0] * vec_dim[1], vec_dim[2]}; dout_.Resize(framework::make_ddim(vec_dim_v)); framework::Tensor x_; - TensorCopy(*x, ctx.GetPlace(), &x_); - ctx.template device_context() - .Wait(); + x_.ShareDataWith(*x); std::vector vec_dim_x = framework::vectorize(x_.dims()); std::vector vec_dim_x_v{vec_dim_x[0] * vec_dim_x[1], vec_dim_x[2]};