Skip to content

Commit

Permalink
Fix req=null in SliceLikeBackward (apache#14209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrendx authored and haohuw committed Jun 23, 2019
1 parent a61a24b commit 84b7043
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/operator/tensor/matrix_op-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<xpu>* s = ctx.get_stream<xpu>();
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<SliceLikeParam>(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) {
Expand Down

0 comments on commit 84b7043

Please sign in to comment.