[PyCUDA] How can I emulated numpy-style index arrays?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PyCUDA] How can I emulated numpy-style index arrays?

Rasmus Diederichsen
Good day, list.

In numpy, one can use arrays of ints to select a non-contiguous subarray, but the same does not work in Pycuda (only slices, ellipses and ints). Is there a straightforward way to emulate this behaviour (maybe use some memcpy call to extract the relevant data)?

Cheers,
Rasmus

_______________________________________________
PyCUDA mailing list
[hidden email]
https://lists.tiker.net/listinfo/pycuda

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How can I emulated numpy-style index arrays?

Syam Gadde

Could you use gpuarray.take()?  There is also apparently an undocumented multi_take(), but I don't know how it works.  If you absolutely need the slicing syntax, it probably wouldn't be hard to modify __getitem__ to use take/multi_take.


-syam



From: PyCUDA <[hidden email]> on behalf of Rasmus Diederichsen <[hidden email]>
Sent: Tuesday, July 24, 2018 5:24:40 AM
To: [hidden email]
Subject: [PyCUDA] How can I emulated numpy-style index arrays?
 
Good day, list.

In numpy, one can use arrays of ints to select a non-contiguous subarray, but the same does not work in Pycuda (only slices, ellipses and ints). Is there a straightforward way to emulate this behaviour (maybe use some memcpy call to extract the relevant data)?

Cheers,
Rasmus

_______________________________________________
PyCUDA mailing list
[hidden email]
https://lists.tiker.net/listinfo/pycuda
Reply | Threaded
Open this post in threaded view
|

Re: How can I emulated numpy-style index arrays?

Rasmus Diederichsen
I was investigating this, but take() only seems to accept an array of integer indices, which would help in the 1d-case, but if I want to do it in multiple dimensions or pass e.g. : for those, it doesn't help. 

I don't understand what's going on in multi_take either, but "multi" seems to be about multiple arrays, not multiple dimensions.

On 24. Jul 2018, at 15:12, Syam Gadde <[hidden email]> wrote:

Could you use gpuarray.take()?  There is also apparently an undocumented multi_take(), but I don't know how it works.  If you absolutely need the slicing syntax, it probably wouldn't be hard to modify __getitem__ to use take/multi_take.

-syam


From: PyCUDA <[hidden email]> on behalf of Rasmus Diederichsen <[hidden email]>
Sent: Tuesday, July 24, 2018 5:24:40 AM
To: [hidden email]
Subject: [PyCUDA] How can I emulated numpy-style index arrays?
 
Good day, list.

In numpy, one can use arrays of ints to select a non-contiguous subarray, but the same does not work in Pycuda (only slices, ellipses and ints). Is there a straightforward way to emulate this behaviour (maybe use some memcpy call to extract the relevant data)?

Cheers,
Rasmus


_______________________________________________
PyCUDA mailing list
[hidden email]
https://lists.tiker.net/listinfo/pycuda

signature.asc (849 bytes) Download Attachment