Skip to content

Feature/dlpack #682

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

Merged
merged 12 commits into from
Dec 1, 2021
Merged

Feature/dlpack #682

merged 12 commits into from
Dec 1, 2021

Conversation

oleksandr-pavlyk
Copy link
Contributor

This PR is split from #646, and contains added support of dpctl.tensor.usm_ndarray of __dlpack__ protocol.

It implements usm_ndarray.__dlpack__ and usm_ndarray.__dlpack_device__ methods. It also implements

dpctl.tensor.from_dlpack(array)

function to convert an array Python object that supports __dlpack__ protocol into usm_ndarray instance without a copy (or raise an error).

@oleksandr-pavlyk
Copy link
Contributor Author

oleksandr-pavlyk commented Nov 20, 2021

This PR is dependent on the merge of #646 , since some test use dpctl.tensor.empty().

@github-actions
Copy link

Added dlpack's license file in include/dlpack/

Added note in README.md about the location of the origin LICENSE file
from which the copy was made

Add _dlpack.pyx to flake exception file

Implemented to_dlpack_capsule/from_dlpack_capsule functions
1. The pycapsule destructor only calls DLManagedTensor.deleter is the name is "dltensor"
2. Code consuming the DLPack capsule renamed the capsule (to avoid destructor calling
   the deleter) and instead creates an internal object to do that and uses
   that internal object as the base of _Memory object

`from_dlpack_capsule` function should handle NULL data field
For zero-elements arrays in DLPack, allocate 1 element

Proper support for strides added.

Expanded docstring of `dpctl.tensor.from_dlpack`
Test should anticipate that dlpack roundtripping changes
bool dtype to uint8

Adding test for `from_dlpack` input validation
@coveralls
Copy link
Collaborator

coveralls commented Nov 23, 2021

Coverage Status

Coverage increased (+0.7%) to 75.51% when pulling 49293af on feature/dlpack into ed8d6ef on master.

1. Added docstrings
2. Exported DLPackCreationError in `_dlpack.pxd`
3. Added validation in `__dlpack_device__` to raise an error
   if device_id came back -1 (not-found)
4. `to_dlpack_capsule(usm_ary)` raises DLPackCreationError
   if the array context is not the default context (the one created
   in dpctl.SyclQueue(dev) call)
@oleksandr-pavlyk
Copy link
Contributor Author

Internal CI failure are unrelated to the functionality proposed in this PR.

@oleksandr-pavlyk oleksandr-pavlyk merged commit a0b840b into master Dec 1, 2021
@oleksandr-pavlyk oleksandr-pavlyk deleted the feature/dlpack branch December 1, 2021 18:47
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants