sxjscience opened a new issue #18084: [Numpy] Backward error in mixed int64 + 
float32
URL: https://github.com/apache/incubator-mxnet/issues/18084
 
 
   This is related to https://github.com/apache/incubator-mxnet/issues/18022.
   
   Reproducible example:
   ```python
   import mxnet as mx
   from mxnet.gluon import HybridBlock
   mx.npx.set_np()
   
   class Foo(HybridBlock):
       def hybrid_forward(self, F, query):
           query_shape = F.npx.shape_array(query)
           return query / query_shape[-1]
   
   foo = Foo()
   foo.hybridize()
   a = mx.np.ones((5, 5, 5))
   out = foo(a)
   print(out)
   
   a.attach_grad()
   with mx.autograd.record():
       out = foo(a)
       out.backward()
   print(a.grad)
   ```
   
   Error message:
   ```
   MXNetError: Traceback (most recent call last):
     File "include/mxnet/./tensor_blob.h", line 256
   MXNetError: Check failed: mshadow: :DataType<DType>::kFlag == type_flag_: 
TBlob.get_with_shape: data type do not match specified type.Expected: long long 
v.s. given float
   ```
   
   Currently, I have to use `query / query_shape[-1].astype(np.float32)`.

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