Skip to content

Feature/dlpack - #682

Merged
oleksandr-pavlyk merged 12 commits into
masterfrom
feature/dlpack
Dec 1, 2021
Merged

oleksandr-pavlyk merged 12 commits into
masterfrom
feature/dlpack

Conversation

@oleksandr-pavlyk

Copy link
Copy Markdown
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

oleksandr-pavlyk commented Nov 20, 2021 •

Copy link
Copy Markdown
Contributor Author

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

@github-actions

Copy link
Copy Markdown

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

coveralls commented Nov 23, 2021 •

Copy link
Copy Markdown
Collaborator

Coverage Status

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

Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_usmarray.pyx Resolved
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)
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
Comment thread dpctl/tensor/_usmarray.pyx Resolved
Comment thread dpctl/tensor/_dlpack.pyx Resolved
@oleksandr-pavlyk

Copy link
Copy Markdown
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

github-actions Bot commented Dec 1, 2021

Copy link
Copy Markdown

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