szha commented on a change in pull request #11948: [MXNET-766] add unroll RNN 
for HybridBlock
URL: https://github.com/apache/incubator-mxnet/pull/11948#discussion_r257046723
 
 

 ##########
 File path: python/mxnet/gluon/contrib/rnn/rnn_cell.py
 ##########
 @@ -315,3 +317,136 @@ def hybrid_forward(self, F, inputs, states, i2h_weight,
 
         return next_r, [next_r, next_c]
     # pylint: enable= arguments-differ
+
+
+def _contrib_format_sequence(inputs, layout, in_layout=None):
+    assert inputs is not None, \
+        "unroll(inputs=None) has been deprecated. " \
+        "Please create input variables outside unroll."
+
+    axis = layout.find('T')
+    batch_axis = layout.find('N')
+    batch_size = 0
+    in_axis = in_layout.find('T') if in_layout is not None else axis
+    assert isinstance(inputs, tensor_types)
+    if isinstance(inputs, symbol.Symbol):
+        F = symbol
+    else:
+        F = ndarray
+        batch_size = inputs.shape[batch_axis]
+
+    if axis != in_axis:
+        inputs = F.swapaxes(inputs, dim1=axis, dim2=in_axis)
+
+    return inputs, axis, F, batch_size
+
+
+def unroll(cell, inputs, begin_state, drop_inputs=0, drop_outputs=0,
+           layout='TNC', valid_length=None):
 
 Review comment:
   suggest renaming

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to