Closed wang-xianghao closed 3 weeks ago
Thanks for pointing this out. This part of the documentation is inaccurate, it should say something like:
Reshaping will trigger a copy in more cases than NumPy (operations that add/remove unitary dimensions, e.g. ``np.ones(3, 4).reshape(3, 1, 4)``, return a view, but those that do not, e.g. ``np.ones(3,4).reshape(12)``, return a copy).
This should be updated on next documentation push.
@manopapad I think even your example might return a view as well. It's when you do a reshape like from something like an (8,3)
array to a (6,4)
array where there's a non-affine mapping between two shapes that we would make a copy. At least that is the way that it used to work.
Thanks @manopapad and @lightsighter. I will use reshape
with caution. By the way, do other shape-related operations, e.g. squeeze()
, transpose()
, expand_dims()
also return a view like numpy?
yes
Hello, The cuNumeric best practices say
reshape
returns a copy rather than a view (Reshape). However, with the sample provided, theassert
successds. I just want to confirm whether the lastest version changesreshape
to make it create a view. Thanks.Environment:
24.9.0.dev0+257.g21c76d03
24.9.0.dev0+96.gbcb6b4aa
Code:
Running command:
Result: The assertion does not fail.