From b7ee1e7d9c7f01844b23c54a3c5a2584e0a6a410 Mon Sep 17 00:00:00 2001 From: dongzhihong Date: Wed, 9 Aug 2017 00:12:09 +0800 Subject: [PATCH] "backward check todo" --- paddle/operators/rowwise_add_op.h | 8 ++++---- python/paddle/v2/framework/tests/test_rowwise_add_op.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/paddle/operators/rowwise_add_op.h b/paddle/operators/rowwise_add_op.h index 06af88a993d..965c0df5325 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 f8521eb5170..e957dd6b3fe 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() -- GitLab