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

bug of NDarray.reshape #18886

Closed
marongxing opened this issue Aug 10, 2020 · 5 comments
Closed

bug of NDarray.reshape #18886

marongxing opened this issue Aug 10, 2020 · 5 comments
Labels

Comments

@marongxing
Copy link

`
In [26]: import mxnet as mx

In [27]: mx.version
Out[27]: '1.6.0'

In [28]: nd = mx.nd

In [29]: a = nd.arange(27).reshape((3,3,3))

In [30]: a.reshape((3,3))
Out[30]:

[[0. 1. 2.]
[3. 4. 5.]
[6. 7. 8.]]
<NDArray 3x3 @cpu(0)>
`
the the old shape (3,3,3) and new shape (3,3) is not in the same size.

is there some special purpose for this?

@leezu leezu added the v1.x Targeting v1.x branch label Aug 10, 2020
@leezu
Copy link
Contributor

leezu commented Aug 10, 2020

I verified that this doesn't affect the np interface: mx.np.arange(27).reshape((3,3)) works as expected on master

@szha
Copy link
Member

szha commented Aug 10, 2020

@cs8105 congrats that you have found mxnet's built-in way of creating memory leaks🤦‍♂️

Joke aside, I think what we need here is a check for consistent size. the logic for ndarray can be found here:
https://github.com/apache/incubator-mxnet/blob/cc287a0fc2de030c5cbb826092cd1863c72931aa/python/mxnet/ndarray/ndarray.py#L1501-L1520

Would you like to open a PR to add a check that makes sure the size is consistent before and after the reshape, and raise ValueError otherwise? The process is described at https://cwiki.apache.org/confluence/display/MXNET/Git+Setup+and+Workflow

@r3stl355
Copy link
Contributor

r3stl355 commented Sep 2, 2020

I'm new so forgive my ignorance. The same bug seems to be present v2.0, shall I just give PR a go on the v2 branch?

@leezu
Copy link
Contributor

leezu commented Sep 2, 2020

@r3stl355 you can open the PR against the master branch and v1.x branch

@r3stl355
Copy link
Contributor

This was fixed by #19095 few months ago and merged into v1.x branch but was not picked for 1.8 release. Should be closed.

@szha szha closed this as completed Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants