Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Bug][Numpy] zeros_like, ones_like does not respect dtype flag #16646

Closed
sxjscience opened this issue Oct 27, 2019 · 2 comments
Closed

[Bug][Numpy] zeros_like, ones_like does not respect dtype flag #16646

sxjscience opened this issue Oct 27, 2019 · 2 comments

Comments

@sxjscience
Copy link
Member

import mxnet as mx
mx.npx.set_np()

a = mx.np.ones((10,10), dtype=mx.np.float32)
b = mx.np.zeros_like(a, dtype=mx.np.int32)
print(b.dtype)

Returns

float32
@xidulu
Copy link
Contributor

xidulu commented Oct 28, 2019

I take a brief look at the infertype function for zeros_like:
https://github.com/apache/incubator-mxnet/blob/master/src/operator/numpy/np_init_op.cc#L103
It seems that, there is no such thing as parameter is this operator.
The following experiment verified my conjecture:

In [1]: from mxnet import np

In [2]: a = np.ones(10)

In [3]: b = np.zeros_like(a, dtype="Life is short, use Pytorch", 
some_param='a', other_param=1, whatever_u_want=True)

In [4]: b
Out[4]: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])

In [5]: b.dtype
Out[5]: dtype('float32')

@Alicia1529
Copy link
Contributor

This bug has been fixed in pr #16804

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants