CuPy to support accepting `order` as a parameter to functions other than `cupy.array`
See original GitHub issueWould it be possible that functions can accept an order
parameter? For example, I would love to use https://docs-cupy.chainer.org/en/stable/reference/generated/cupy.random.standard_normal.html#cupy.random.standard_normal with order='F'
. As it stands, the only way to convert a C
matrix to F
is by doing X = cp.array(X, order='F')
. This temporarily blows up memory usage to 2x as it is most likely creating a copy of the transpose, I believe. For memory intensive applications, this is not the best as OOMs are common.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Interoperability — CuPy 11.4.0 documentation
DLPack data exchange protocol The function cupy. from_dlpack() accepts such object and returns a cupy. ndarray that is safely accessible on CuPy's current ......
Read more >Differences between CuPy and NumPy
Unlike NumPy, Universal Functions in CuPy only work with CuPy array or scalar. They do not accept other objects (e.g., lists or numpy.ndarray...
Read more >cupy.ndarray — CuPy 11.4.0 documentation
Multi-dimensional array on a CUDA device. This class implements a subset of methods of numpy.ndarray . The difference is that this class allocates...
Read more >Basics of CuPy — CuPy 11.4.0 documentation
cupy. asarray() can accept cupy. ndarray , which means we can transfer the array between devices with this function. cupy.
Read more >v9.1.0 PDF - CuPy Documentation
Unlike NumPy, Universal Functions in CuPy only work with CuPy array or scalar. They do not accept other objects.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@leofang upon more testing, that works but this is also what works for me:
X = X.T.reshape(X.shape, order='F')
The problem with the approach you suggested is that I am using the covariance matrix to verify whether my PCA algorithm worked correctly. Reshaping point samples of size
n
to form1D samples
would not reproduce the same covariance matrix for me from PCA, I believe, as then the columns would become features of their own. If you could verify for me if my approach is correct, then it would be really helpful! 😃Hi! Thanks for the feedback. With random functions, all the elements are generated independently so just transposing the matrix should give you a Fortran order matrix without an additional copy.
For the random package, NumPy does not support the
order
argument for the routines. So in order to keep as close as possible to NumPy we won’t be adding such option. But we are working on adding Generalized Universal Functions, so thatorder
will be an argument of several NumPy core routines.