From 0cf5bdec563c4360f36c90ced8a73c7493874bf4 Mon Sep 17 00:00:00 2001 From: dongzhihong Date: Fri, 18 Aug 2017 14:24:24 -0700 Subject: [PATCH] "tensor mutable data" --- paddle/operators/mul_op.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/operators/mul_op.h b/paddle/operators/mul_op.h index 9bbd0275261..8facc028144 100644 --- a/paddle/operators/mul_op.h +++ b/paddle/operators/mul_op.h @@ -51,9 +51,11 @@ class MulGradKernel : public framework::OpKernel { auto* dX = ctx.Output(framework::GradVarName("X")); auto* dY = ctx.Output(framework::GradVarName("Y")); + dX->mutable_data(ctx.GetPlace()); + dY->mutable_data(ctx.GetPlace()); auto* device_context = const_cast(ctx.device_context_); - // dX = dOut' * Y. dX: M x K, dOut : M x N, Y : K x N + // dX = dOut * Y'. dX: M x K, dOut : M x N, Y : K x N math::matmul(*dOut, false, *Y, true, 1, dX, 0, device_context); // dY = X' * dOut. dY: K x N, dOut : M x N, X : M x K math::matmul(*X, true, *dOut, false, 1, dY, 0, device_context); -- GitLab