sxjscience opened a new issue #16279: [Bug] Inconsistency between HybridBlock 
and Block
URL: https://github.com/apache/incubator-mxnet/issues/16279
 
 
   There are lots of operators that have inconsistent behaviors between 
hybridized and not-hybridized versions.
   
   ```python
   import mxnet as mx
   from mxnet.gluon import HybridBlock
   
   class Foo2(HybridBlock):
       def hybrid_forward(self, F, a):
           return a[0]
   
   
   b1 = Foo2(prefix='hybridized')
   b1.hybridize()
   b2 = Foo2(prefix='no_hybrid')
   
   out1 = b1(mx.nd.ones((10,)))
   out2 = b2(mx.nd.ones((10,)))
   print(out1)
   print(out2)
   
   ```
   ```log
   [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
   <NDArray 10 @cpu(0)>
   
   [1.]
   <NDArray 1 @cpu(0)>
   ```
   
   Even if we use the `numpy` interface, the following code cannot  run:
   
   ```python
   import mxnet as mx
   from mxnet.gluon import HybridBlock
   mx.npx.set_np()
   
   
   class Foo2(HybridBlock):
       def hybrid_forward(self, F, a):
           return a[0]
   
   
   b1 = Foo2(prefix='hybridized')
   b1.hybridize()
   b2 = Foo2(prefix='no_hybrid')
   
   out1 = b1(mx.np.ones((10,)))
   out2 = b2(mx.np.ones((10,)))
   print(out1)
   print(out2)
   ```
   
   ```log
         6 class Foo2(HybridBlock):
         7     def hybrid_forward(self, F, a):
   ----> 8         return a[0]
         9 
        10 
   
   ~/mxnet/python/mxnet/symbol/numpy/_symbol.py in __getitem__(self, key)
        49         num_outputs = _num_outputs(self)
        50         if num_outputs == 1:
   ---> 51             raise NotImplementedError
        52         if not isinstance(key, int):
        53             raise NotImplementedError
   
   NotImplementedError: 
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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