-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 ofarr
ifbool(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_ndarray
of 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_ndarray
of requested data-type from pointer and queue reference;owner=None
is interpreter as transfer of memory ownership, and memory will be deallocated once the usm_ndarray instance is deleted. Ifowner
is notNone
, deleter ofusm_ndarray
instance will call the deleter ofowner
which is supposed to clean up the USM allocation. Theowner
object 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_capi
singleton class, but are yet unused.@samir-nasibli