diff --git a/paddle/operators/rowwise_add_op.h b/paddle/operators/rowwise_add_op.h index 06af88a993d19bb03ae468b468cbfef3b782d5f0..965c0df5325a39558e70842d04648a9223ca06f9 100644 --- a/paddle/operators/rowwise_add_op.h +++ b/paddle/operators/rowwise_add_op.h @@ -42,18 +42,18 @@ template class RowwiseAddGradKernel : public OpKernel { public: void Compute(const ExecutionContext& context) const override { - auto XGrad = context.Output(0); - auto bGrad = context.Output(1); + auto* XGrad = context.Output(0); + auto* bGrad = context.Output(1); XGrad->mutable_data(context.GetPlace()); bGrad->mutable_data(context.GetPlace()); // I, O, OG => [X, b], [Out], [OutGrad] auto OutGrad = EigenMatrix::From(*context.Input(3)); - EigenMatrix::From(*XGrad).device(*(context.GetEigenDevice())) = + EigenMatrix::From(*XGrad).device(context.GetEigenDevice()) = OutGrad; // https://eigen.tuxfamily.org/dox/unsupported/TensorBase_8h_source.html - EigenVector::Flatten(*bGrad).device(*(context.GetEigenDevice())) = + EigenVector::Flatten(*bGrad).device(context.GetEigenDevice()) = OutGrad.cumsum(1); // colwise add } }; diff --git a/python/paddle/v2/framework/tests/test_rowwise_add_op.py b/python/paddle/v2/framework/tests/test_rowwise_add_op.py index f8521eb517057fbeb104b28af7da4fffe54f37de..e957dd6b3fe50632d889fc7935654756e97ec6e0 100644 --- a/python/paddle/v2/framework/tests/test_rowwise_add_op.py +++ b/python/paddle/v2/framework/tests/test_rowwise_add_op.py @@ -15,5 +15,7 @@ class TestRowwiseAddOp(unittest.TestCase): self.outputs = {'Out': np.add(self.inputs['X'], self.inputs['b'])} +#TODO(dzh): rowwise_grad check + if __name__ == '__main__': unittest.main()