How would I copy data from an ArrayFire array to a regular Python array on the host CPU in wrapper?

218 views
Skip to first unread message

Cole Shores

unread,
Mar 29, 2016, 1:26:47 PM3/29/16
to ArrayFire Users
How would I copy array data from an ArrayFire array to a regular python array on the host CPU using the Python wrapper?
I know I could use a host pointer to the data using C/C++ but Im not sure how that is accomplished using this wrapper.
How would I copy my array data to and from ArrayFire?
Thanks in advance,
Cole

Anubhab Haldar

unread,
Mar 29, 2016, 2:35:53 PM3/29/16
to ArrayFire Users
On C++, this works like this:

array a = <array data here>
float ahost[] = a.host()

There may be something similar in Python that implements this functionality.

Pavan Yalamanchili

unread,
Mar 29, 2016, 4:16:37 PM3/29/16
to Anubhab Haldar, ArrayFire Users
Hi Cole,

Anubhab is right. The proper function for this is to call a.to_array(). You can get a python list by using a.to_list().

You can look at other methods by starting python (or ipython) REPL and running help(af.Array)


If you'd prefer, you can use our chatroom for some quick responses: https://gitter.im/arrayfire/arrayfire-python

--
Pavan


--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/1974ba5a-1ec9-439c-bafe-8669fb6b1f40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages