Add usm_ndarray creation c-api#1050
Conversation
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/1050/index.html |
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_55 ran successfully. |
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_56 ran successfully. |
|
Right now |
e471c15 to
f40d7e6
Compare
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_59 ran successfully. |
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_60 ran successfully. |
Added UsmNDArray_MakeFromMemory, UsmNDArray_SetWritableFlag, UsmNDArray_MakeFromPtr C-functions.
Used ctypes to call new C-API for dpctl.tensor.usm_ndarray
ea67d57 to
5145923
Compare
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_64 ran successfully. |
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
|
Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_70 ran successfully. |
Closes #1049
This PR adds 3 new C-API for usm_ndarray:
void UsmNDArray_SetWritableFlag(usm_array arr, int flag): Set WRITABLE flag ofarrifbool(flag)isTrue, and clears it otherwiseobject UsmNDArray_MakeFromMemory(int nd, const Py_ssize_t *shape, int typenum, c_dpmem._Memory memobj, Py_ssize_t offset): createusm_ndarrayof given shape and data-type from USM-memory object and offsetobject UsmNDArray_MakeFromPtr(size_t nelems, int typenum, DPCTLSyclUSMRef ptr, DPCTLSyclQueueRef QRef, object owner): create 1Dusm_ndarrayof requested data-type from pointer and queue reference;owner=Noneis interpreter as transfer of memory ownership, and memory will be deallocated once the usm_ndarray instance is deleted. Ifowneris notNone, deleter ofusm_ndarrayinstance will call the deleter ofownerwhich is supposed to clean up the USM allocation. Theownerobject must thus capture the pointer and the queue reference, or the context to make the correct call tosycl::free.ctypes-based tests are added to the test-suite.New C-API functions are added to
dpctl::detail::dpctl_capisingleton class, but are yet unused.@samir-nasibli