arcadiaphy opened a new issue #17785: Inconsistency between HybridBlock and 
Block
URL: https://github.com/apache/incubator-mxnet/issues/17785
 
 
   Following #16279, another example of inconsistency between HybridBlock and 
Block:
   
   ```
   import mxnet as mx
   from mxnet.gluon import HybridBlock
   
   class Foo(HybridBlock):
       def hybrid_forward(self, F, a, b):
           return a + b
   
   
   b1 = Foo(prefix='non_hybrid')
   b2 = Foo(prefix='hybrid')
   b2.hybridize()
   
   print(b1(mx.nd.ones((10,)), mx.nd.ones((1,))))
   print(b2(mx.nd.ones((10,)), mx.nd.ones((1,))))
   ```
   
   MXNetError is triggered for non-hybridized case:
   
   ```
   MXNetError: MXNetError: Error in operator hybridized_plus0: [14:24:15] 
src/operator/numpy/linalg/../../tensor/../elemwise_op_common.h:135: Check 
failed: assign(&dattr, vec.at(i)): Incompatible attr in node hybridized_plus0 
at 1-th input: expected [10], got [1]
   ```
   
   I think it's because for symbol, `elemwise_add` is used for `__add__`, while 
for ndarray broadcasting is considered in `__add__` considering input shape.
   
   Can we add broadcasting in symbol too and avoid the need to differentiate 
between `elemwise_add` and `broadcast_add`?
   
   Note that the same problem exists in subtract, multiply and divide 
operation, too.

----------------------------------------------------------------
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