From 84b7043c431e9014da07c2fe89f1ef21c595aea9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Tredak Date: Tue, 19 Feb 2019 16:03:36 -0800 Subject: [PATCH] Fix req=null in SliceLikeBackward (#14209) --- src/operator/tensor/matrix_op-inl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/operator/tensor/matrix_op-inl.h b/src/operator/tensor/matrix_op-inl.h index 97c4fa55681c..28ed4215e0a7 100644 --- a/src/operator/tensor/matrix_op-inl.h +++ b/src/operator/tensor/matrix_op-inl.h @@ -1389,13 +1389,15 @@ void SliceLikeBackward(const nnvm::NodeAttrs& attrs, CHECK_EQ(inputs.size(), 1U); CHECK_EQ(outputs.size(), 2U); CHECK_EQ(req.size(), 2U); - if (req[0] == kNullOp) return; using namespace mshadow; Stream* s = ctx.get_stream(); + if (req[1] != kNullOp && req[1] != kAddTo) { + Fill(s, outputs[1], req[1], 0); // Second input not relavant to gradients. + } + if (req[0] == kNullOp) return; const TBlob& ograd = inputs[0]; const TBlob& igrad = outputs[0]; const SliceLikeParam& param = nnvm::get(attrs.parsed); - Fill(s, outputs[1], req[1], 0); // Second input not relavant to gradients. if (req[0] == kWriteTo) { Fill(s, igrad, req[0], 0); } else if (req[0] == kWriteInplace) {