Skip to content
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

Support kDLCPU DLDeviceType for from_dlpack and __dlpack__ #1781

Merged
merged 22 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ad1c5f
Support `kDLCPU` devices via DLPack protocol
ndgrigorian Aug 2, 2024
a250506
Refactor _dlpack.pyx functions
ndgrigorian Aug 2, 2024
d326314
Fix Cython warning caused by cimporting from Numpy
ndgrigorian Aug 2, 2024
1ec9a76
Handle Numpy deprecated API without touching CMake
ndgrigorian Aug 3, 2024
7b6a651
Introduce _is_host_cpu utility predicate used in __dlpack__
oleksandr-pavlyk Aug 5, 2024
d393950
Merge pull request #1784 from IntelPython/factor-out-dl-device-check
oleksandr-pavlyk Aug 5, 2024
c3655ed
Fixes a typo when making NumPy array interface from a boolean array i…
ndgrigorian Aug 5, 2024
cb80f55
Adds validation for `dl_device` argument in `__dlpack__`
ndgrigorian Aug 5, 2024
3c35c3b
Chane per PR review by @oleksandr-pavlyk and pass NULL strides to dl_…
ndgrigorian Aug 5, 2024
f781400
Adds tests for DLPack using `kDLCPU` dl_device
ndgrigorian Aug 5, 2024
1544e9b
Clean up errors in `__dlpack__`
ndgrigorian Aug 6, 2024
70c6772
Re-order conditional strides assignment
ndgrigorian Aug 6, 2024
fe71e99
Prevent losing reference of DLPack holder when returning NumPy array
ndgrigorian Aug 6, 2024
85d417f
Expose `DLDeviceType` in `dpctl.tensor`
ndgrigorian Aug 8, 2024
5ae872a
Docstring for DLDeviceType listing the valid enumerators
ndgrigorian Aug 8, 2024
353be0d
Add documentation for constants and `DLDeviceType` enums
ndgrigorian Aug 8, 2024
2bd92df
Merge pull request #1793 from IntelPython/document-dldevicetype-const…
oleksandr-pavlyk Aug 8, 2024
a30b573
Merge branch 'master' into feature/dlpack-kdlcpu-support
oleksandr-pavlyk Aug 8, 2024
4c360d3
Add _is_kdlcpu_device utility to _dlpack.pyx
ndgrigorian Aug 9, 2024
dd4c0c0
Minor change to `_is_kdlcpu_device`
ndgrigorian Aug 9, 2024
2661f51
Support copy-via-host in from_dlpack
oleksandr-pavlyk Aug 7, 2024
9a17afc
Merge pull request #1789 from IntelPython/enhance-from_dlpack
oleksandr-pavlyk Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/doc_sources/api_reference/dpctl/tensor.constants.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _dpctl_tensor_constants:

Constants
========================

The following constants are defined in :py:mod:`dpctl.tensor`:

.. currentmodule:: dpctl.tensor

.. autodata:: DLDeviceType

.. data:: e

``float``:
IEEE 754 floating-point representation of Euler's constant.

.. data:: inf

``float``:
IEEE 754 floating-point representation of (positive) infinity.

.. data:: nan

``float``:
IEEE 754 floating-point representation of Not a Number (NaN).

.. data:: newaxis

``NoneType``:
Alias for ``None`` which is useful for indexing.

.. data:: pi

``float``:
IEEE 754 floating-point representation of the mathematical constant π.
2 changes: 2 additions & 0 deletions docs/doc_sources/api_reference/dpctl/tensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This module contains:
* :ref:`sorting functions <dpctl_tensor_sorting_functions>`
* :ref:`statistical functions <dpctl_tensor_statistical_functions>`
* :ref:`utility functions <dpctl_tensor_utility_functions>`
* :ref:`constants <dpctl_tensor_constants>`


.. toctree::
Expand All @@ -48,3 +49,4 @@ This module contains:
tensor.sorting_functions
tensor.statistical_functions
tensor.utility_functions
tensor.constants
3 changes: 2 additions & 1 deletion dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
from dpctl.tensor._reshape import reshape
from dpctl.tensor._search_functions import where
from dpctl.tensor._statistical_functions import mean, std, var
from dpctl.tensor._usmarray import usm_ndarray
from dpctl.tensor._usmarray import DLDeviceType, usm_ndarray
from dpctl.tensor._utility_functions import all, any, diff

from ._accumulation import cumulative_logsumexp, cumulative_prod, cumulative_sum
Expand Down Expand Up @@ -383,5 +383,6 @@
"nextafter",
"diff",
"count_nonzero",
"DLDeviceType",
"take_along_axis",
]
7 changes: 6 additions & 1 deletion dpctl/tensor/_dlpack.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
# cython: language_level=3
# cython: linetrace=True

cdef extern from "numpy/npy_no_deprecated_api.h":
pass
from numpy cimport ndarray

from .._sycl_device cimport SyclDevice
from ._usmarray cimport usm_ndarray

Expand All @@ -40,7 +44,8 @@ cdef extern from 'dlpack/dlpack.h' nogil:

cpdef object to_dlpack_capsule(usm_ndarray array) except +
cpdef object to_dlpack_versioned_capsule(usm_ndarray array, bint copied) except +
cpdef usm_ndarray from_dlpack_capsule(object dltensor) except +
cpdef object numpy_to_dlpack_versioned_capsule(ndarray array, bint copied) except +
cpdef object from_dlpack_capsule(object dltensor) except +

cdef int get_parent_device_ordinal_id(SyclDevice dev) except *

Expand Down
Loading
Loading