From 9189bcff2c88d01ae37fa3eca5239f1d09c3a2e2 Mon Sep 17 00:00:00 2001 From: Kellen Sunderland Date: Thu, 20 Sep 2018 14:15:44 -0700 Subject: [PATCH] [MXNET-969] Use ternary op for statecell --- src/operator/rnn-inl.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/operator/rnn-inl.h b/src/operator/rnn-inl.h index 4955c586f247..3ab6d2981032 100644 --- a/src/operator/rnn-inl.h +++ b/src/operator/rnn-inl.h @@ -553,12 +553,6 @@ class RNNOp : public Operator{ DType* reserve_space_ptr = static_cast(reserve_space_.dptr); - int req_statecell = 0; - if (param_.mode == rnn_enum::kLstm) { - // State cell should be present for LSTMs. - req_statecell = req[rnn_enum::kStateCell]; - } - RNNBackward(workspace.dptr_, reserve_space_ptr, param_.num_layers, @@ -583,7 +577,8 @@ class RNNOp : public Operator{ req[rnn_enum::kData], req[rnn_enum::kParams], req[rnn_enum::kState], - req_statecell, + // State cell should be present for LSTMs, but is absent for other RNNs. + param_.mode == rnn_enum::kLstm ? req[rnn_enum::kStateCell] : kNullOp, param_.p, param_.mode); }