szha commented on a change in pull request #8050: fix symbolblock
URL: https://github.com/apache/incubator-mxnet/pull/8050#discussion_r141239287
 
 

 ##########
 File path: python/mxnet/gluon/block.py
 ##########
 @@ -487,8 +487,8 @@ def __init__(self, outputs, inputs, params=None):
         self._params = ParameterDict('', params)
         if isinstance(inputs, symbol.Symbol) and len(inputs.list_outputs()) == 
1:
             inputs = [inputs]
-        if isinstance(outputs, symbol.Symbol) and len(outputs.list_outputs()) 
== 1:
-            outputs = [outputs]
+        if isinstance(outputs, (list, tuple)) and len(outputs) == 1:
+            outputs = outputs[0]
 
 Review comment:
   I actually find the inconsistent type a bit tricky to deal with. For example
   ```python
   In [3]: type(mx.nd.ones((3,5)).split(3, axis=0))
   Out[3]: list
   
   In [4]: type(mx.nd.ones((3,5)).split(1, axis=0))
   Out[4]: mxnet.ndarray.ndarray.NDArray
   ```
   
   Pytorch does it more consistently. `torch.chunk` always returns a tuple even 
when length is 1.
 
----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to