Skip to content

Commit 8b42313

Browse files
Update dlpack to v1.0rc (#1667)
* Implements DLPack changes necessitated by memory object work Use `ary_base` rather than `usm_ary` as manager_ctx in DLManagedTensor struct. Tests for DLPack use fixture to provide all devices to take advantage of caching. * `usm_ndarray` constructor now honors the writable flag when passed a read-only array as `buffer` argument * Adds support for DLPack v1.0 * Uses `dlpack.h` as per DLPack v1.0 rc * Implements `device` and `copy` keywords into `__dlpack__` and `from_dlpack` * Implements `max_version` argument into `__dlpack__` * Adds `DLDeviceType` enumerator to `_usmarray.pyx` for representing device types as enumerators * Reimplements `dpt._dlpack.get_build_dlpack_version` to return a tuple of the major version and the minor version * Adds check for major version of versioned dlpack tensor to `from_dlpack_versioned_capsule` Also adjusts some error messages in _dlpack.pyx * Add missing device_type enumerators from `dlpack.h` * usm_ary -> ary_base in `to_dlpack_versioned_capsule` * Changes to exception messages throughout _dlpack.pyx * Versioned DLpack tensor deleter and owner tweaked These tweaks are based on similar changes made for the managed tensor during memory work * Updates `dpctl/tensor/include/dlpack/README.md` DLPack version updated and new SHA for `dlpack.h` added * Adds check that `max_version` is a 2-tuple to `__dlpack__` * Add more dlpack tests (#1670) * Fixture all_root_devices is to keep only 2 devices from each platform This is done to speed-up test suite execution on multi-GPU system, like Aurora. * Add tests for legacy/versions capsule import-export * Expand tests more to improve coverage Use F-contiguous array to both legacy and versioned capsule. Add tests for read-only array and for use of copy=True keyword for __dlpack__ call * Test the writable flag of a usm_ndarray from read-only DLPack capsule Also adds a test checking for the writable flag of a usm_ndarray constructed with a read-only usm_ndarray as the buffer Removes some commented out `flags` checks from `test_meshgrid2`. These checks were malformed, as `dpt.meshgrid` returns a non-contiguous view in the test. * Factor out device-id computation Reuse that in both capsule producers to avoid code duplication * Reuse get parent device ordinal id routine (#1672) * Reused get_parent_device_ordinal_id routine * test_legacy_dlpack_capsule uses 4 kinds of dtype Added test to use non-default copy keyword, and non-default device keyword argument. * Adds more DLPack tests to improve coverage * Adds a test for boolean arrays in test_legacy_dlpack_capsule * DLPack tests for `copy` and `stream` kwargs in `__dlpack__` --------- Co-authored-by: Oleksandr Pavlyk <[email protected]>
1 parent d3e124a commit 8b42313

File tree

7 files changed

+1026
-118
lines changed

7 files changed

+1026
-118
lines changed

dpctl/tensor/_dlpack.pxd

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,24 @@ from ._usmarray cimport usm_ndarray
2424

2525
cdef extern from 'dlpack/dlpack.h' nogil:
2626
int device_CPU 'kDLCPU'
27-
int device_oneAPI 'kDLOneAPI'
27+
int device_CUDA 'kDLCUDA'
28+
int device_CUDAHost 'kDLCUDAHost'
29+
int device_CUDAManaged 'kDLCUDAManaged'
30+
int device_DLROCM 'kDLROCM'
31+
int device_ROCMHost 'kDLROCMHost'
2832
int device_OpenCL 'kDLOpenCL'
29-
33+
int device_Vulkan 'kDLVulkan'
34+
int device_Metal 'kDLMetal'
35+
int device_VPI 'kDLVPI'
36+
int device_OneAPI 'kDLOneAPI'
37+
int device_WebGPU 'kDLWebGPU'
38+
int device_Hexagon 'kDLHexagon'
39+
int device_MAIA 'kDLMAIA'
3040

3141
cpdef object to_dlpack_capsule(usm_ndarray array) except +
42+
cpdef object to_dlpack_versioned_capsule(usm_ndarray array, bint copied) except +
3243
cpdef usm_ndarray from_dlpack_capsule(object dltensor) except +
3344

34-
cpdef from_dlpack(array)
35-
3645
cdef int get_parent_device_ordinal_id(SyclDevice dev) except *
3746

3847
cdef class DLPackCreationError(Exception):

0 commit comments

Comments
 (0)