You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For arr that supports DLPack, version (1, 0),
or legacy, support
```
from_dlpack(arr, device=target_dev)
```
where target_dev is `(kDLCPU, 0)` for transfer to
host, or a value recognized by device keywords
in dpctl.tensor for other functions, or `(kDLOneAPI, dev_id)`.
To support transfer via host, `arr` must support
`__dlpack__(max_version=(1,0), dl_device=(1, 0))`.
For array objects with legacy `__dlpack__` support only,
supported inputs are those residing on kDLCPU device, or
those from kDLOneAPI device only.
---
This is a combination of 17 commits squashed into one:
Combine two validation checks into one, improving coverage
Only fall-back to __dlpack__() if requested device does not change
Simplify branching, only fall-back to no-arg call to __dlpack__ is
dl_device is None or same as reported for the input
Changed from_dlpack to copy via host is needed
This enables dpt.from_dlpack(numpy_array, device="opencl:cpu")
Add a test to exercise copy via host
Handle possibilities for TypeError and BufferError
These may be hard to test
Change exception raised by __dlpack__ if dl_device is unsupported
It used to raise NotImplementedError, not raises BufferError
Add case of dlpack test to expand coverage
Removed comment, add NotImplementedError to the except clause
To ensure same validation across branches, compute host_blob by roundtripping it through dlpack
Test from_dlpack on numpy input with strides not multiple of elementsize
Refined from_dlpack docstrings, reorged impl of from_dlpack
Used try/except/else/finally to avoid raising an exception when
another one is in flight (confusing UX).
device keyword is only allowed to be (kDLCPU, 0) or
(kDLOneAPI, num). Device keyword value is used to create output
array, rather than device_id deduced from it.
Adjusted test per change in implementation
Expand applicability of fall-back behavior
When `from_dlpack(arr, device=dev)` is called, for `arr` object
that supports legacy DLPack interface (max_version, dl_device, copy
are not supported), we now support arr being device on host, that
is (kDLCPU, 0), and (kDLOneAPI, different_device_id). Support for
this last case is being added in this commit, as per review comment.
Add symmetric support for containers with legacy DLPack support
For legacy containers, support device=(kDLCPU, 0) as well as
oneAPI device.
Add tests for importing generic legacy and generic modern containers
Fix typos in comments
Add test for legacy container holding numpy's array.
0 commit comments