From e79841de9172329950b6ec1af00282321975c324 Mon Sep 17 00:00:00 2001 From: xutianbing Date: Wed, 25 Jan 2017 10:35:47 -0800 Subject: [PATCH] fix test_LayerGrad. --- paddle/function/ContextProjectionOp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/function/ContextProjectionOp.cpp b/paddle/function/ContextProjectionOp.cpp index d81ea584016..b87750b7424 100644 --- a/paddle/function/ContextProjectionOp.cpp +++ b/paddle/function/ContextProjectionOp.cpp @@ -132,7 +132,7 @@ public: auto out_mat = out_seq.matrix(); const auto in_mat = val_seqs.matrix(); const auto w_mat = - (2UL == inputs.size()) + (2UL == inputs.size() && inputs[1].data()) ? inputs[1].matrix() : typename Tensor::Matrix(nullptr, 0, 0); const auto seq_vec = val_seqs.getSequenceId().vector(); @@ -263,7 +263,7 @@ public: !out_seq.data() ? typename Tensor::Matrix(nullptr, 0, 0) : out_seq.matrix(); auto w_grad_mat = - (2UL == outputs.size()) + (2UL == outputs.size() && outputs[1].data()) ? outputs[1].matrix() : typename Tensor::Matrix(nullptr, 0, 0); -- GitLab