Skip to content

Commit 72a18a1

Browse files
Merge branch 'move_usm_ndarray' into move_dpctl_ext_to_dpnp_tensor
2 parents 5b7600c + 33fc8fc commit 72a18a1

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

dpnp/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
[os.getenv("PATH", ""), dll_path]
6161
)
6262

63+
# TODO: revert to `from dpctl.tensor...`
64+
# when dpnp fully migrates dpctl/tensor
65+
from dpctl_ext.tensor import __array_api_version__, DLDeviceType
6366

6467
from .dpnp_array import dpnp_array as ndarray
6568
from .dpnp_array_api_info import __array_namespace_info__

dpnp/dpnp_iface_statistics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
import dpnp.backend.extensions.statistics._statistics_impl as statistics_ext
5151
import dpnp.tensor as dpt
5252
import dpnp.tensor._tensor_elementwise_impl as ti
53-
from dpnp.dpnp_utils.dpnp_utils_common import (
54-
result_type_for_device,
55-
to_supported_dtypes,
56-
)
5753
from dpnp.tensor._numpy_helper import normalize_axis_index
5854

5955
from .dpnp_utils import get_usm_allocations
56+
from .dpnp_utils.dpnp_utils_common import (
57+
result_type_for_device,
58+
to_supported_dtypes,
59+
)
6060
from .dpnp_utils.dpnp_utils_reduction import dpnp_wrap_reduction_call
6161
from .dpnp_utils.dpnp_utils_statistics import dpnp_cov, dpnp_median
6262

dpnp/tensor/_dlpack.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ def from_dlpack(x, /, *, device=None, copy=None):
10861086
.. code-block:: python
10871087
10881088
import dpctl
1089-
import dpctl.tensor as dpt
1089+
import dpctl_ext.tensor as dpt
10901090
10911091
class Container:
10921092
"Helper class implementing `__dlpack__` protocol"

dpnp/tensor/_usmarray.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ cdef class usm_ndarray:
465465
466466
.. code-block:: python
467467
468-
from dpctl import tensor
468+
from dpctl_ext import tensor
469469
470470
x = tensor.ones((3, 10, 7))
471471
y = tensor.flip(x[:, 1::2], axis=1)
@@ -659,7 +659,7 @@ cdef class usm_ndarray:
659659
660660
.. code-block:: python
661661
662-
from dpctl import tensor
662+
from dpctl_ext import tensor
663663
664664
x = tensor.arange(899)
665665
x.shape = (29, 31)
@@ -764,7 +764,7 @@ cdef class usm_ndarray:
764764
765765
.. code-block:: python
766766
767-
from dpctl import tensor
767+
from dpctl_ext import tensor
768768
769769
x = tensor.zeros((20, 30))
770770
xv = x[10:, :15]
@@ -877,7 +877,7 @@ cdef class usm_ndarray:
877877
878878
.. code-block:: python
879879
880-
>>> from dpctl import tensor
880+
>>> from dpctl_ext import tensor
881881
>>> x = tensor.ones(10)
882882
>>> x.device
883883
Device(level_zero:gpu:0)
@@ -928,7 +928,7 @@ cdef class usm_ndarray:
928928
929929
.. code-block:: python
930930
931-
from dpctl import tensor
931+
from dpctl_ext import tensor
932932
933933
# Create complex array from
934934
# arrays of real and imaginary parts
@@ -957,7 +957,7 @@ cdef class usm_ndarray:
957957
958958
.. code-block:: python
959959
960-
from dpctl import tensor
960+
from dpctl_ext import tensor
961961
962962
# Reset imaginary part of complex array
963963
@@ -1049,7 +1049,7 @@ cdef class usm_ndarray:
10491049
.. code-block:: python
10501050
10511051
import dpctl
1052-
import dpctl.tensor as dpt
1052+
import dpctl_ext.tensor as dpt
10531053
10541054
x = dpt.full(10**6, 2, dtype="int64")
10551055
q_prof = dpctl.SyclQueue(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DLPack header
22

3-
The header `dlpack.h` downloaded from `https://github.com/dmlc/dlpack.git` remote at tag v1.0rc commit [`62100c1`](https://github.com/dmlc/dlpack/commit/62100c123144ae7a80061f4220be2dbd3cbaefc7).
3+
The header `dlpack.h` downloaded from `https://github.com/dmlc/dlpack.git` remote at tag v1.3 commit [`84d107b`](https://github.com/dmlc/dlpack/commit/84d107bf416c6bab9ae68ad285876600d230490d).
44

5-
The file can also be viewed using github web interface at https://github.com/dmlc/dlpack/blob/62100c123144ae7a80061f4220be2dbd3cbaefc7/include/dlpack/dlpack.h
5+
The file can also be viewed using github web interface at https://github.com/dmlc/dlpack/blob/v1.3/include/dlpack/dlpack.h
66

77
License file was retrieved from https://github.com/dmlc/dlpack/blob/main/LICENSE

dpnp/tensor/include/dlpack/dlpack.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define DLPACK_MAJOR_VERSION 1
2020

2121
/*! \brief The current minor version of dlpack */
22-
#define DLPACK_MINOR_VERSION 2
22+
#define DLPACK_MINOR_VERSION 3
2323

2424
/*! \brief DLPACK_DLL prefix for windows */
2525
#ifdef _WIN32
@@ -397,7 +397,7 @@ typedef enum
397397
} DLManagedTensorVersioned;
398398

399399
//----------------------------------------------------------------------
400-
// DLPack `__c_dlpack_exchange_api__` fast exchange protocol definitions
400+
// DLPack `__dlpack_c_exchange_api__` fast exchange protocol definitions
401401
//----------------------------------------------------------------------
402402
/*!
403403
* \brief Request a producer library to create a new tensor.
@@ -442,6 +442,7 @@ typedef enum
442442
*
443443
* \param py_object The Python object to convert. Must have the same type
444444
* as the one the `DLPackExchangeAPI` was discovered from.
445+
* \param out The output DLManagedTensorVersioned.
445446
* \return The owning DLManagedTensorVersioned* or NULL on failure with a
446447
* Python exception set. If the data cannot be described using
447448
* DLPack this should be a BufferError if possible. \note - As a C function,
@@ -561,17 +562,24 @@ typedef enum
561562
* \brief Framework-specific function pointers table for DLPack exchange.
562563
*
563564
* Additionally to `__dlpack__()` we define a C function table sharable by
564-
* Python implementations via `__c_dlpack_exchange_api__`.
565-
* This attribute must be set on the type as a Python integer compatible
566-
* with `PyLong_FromVoidPtr`/`PyLong_AsVoidPtr`.
565+
*
566+
* Python implementations via `__dlpack_c_exchange_api__`.
567+
* This attribute must be set on the type as a Python PyCapsule
568+
* with name "dlpack_exchange_api".
567569
*
568570
* A consumer library may use a pattern such as:
569571
*
570572
* \code
571573
*
572-
* PyObject *api_obj = type(tensor_obj).__c_dlpack_exchange_api__; // as
573-
* C-code MyDLPackExchangeAPI *api = PyLong_AsVoidPtr(api_obj); if (api ==
574-
* NULL && PyErr_Occurred()) { goto handle_error; }
574+
* PyObject *api_capsule = PyObject_GetAttrString(
575+
* (PyObject *)Py_TYPE(tensor_obj), "__dlpack_c_exchange_api__")
576+
* );
577+
* if (api_capsule == NULL) { goto handle_error; }
578+
* MyDLPackExchangeAPI *api = (MyDLPackExchangeAPI *)PyCapsule_GetPointer(
579+
* api_capsule, "dlpack_exchange_api"
580+
* );
581+
* Py_DECREF(api_capsule);
582+
* if (api == NULL) { goto handle_error; }
575583
*
576584
* \endcode
577585
*
@@ -652,7 +660,7 @@ typedef enum
652660
/*!
653661
* \brief Producer function pointer for DLPackManagedTensorToPyObject
654662
* This function must be not NULL.
655-
* \sa DLPackManagedTensorToPyObject
663+
* \sa DLPackManagedTensorToPyObjectNoSync
656664
*/
657665
DLPackManagedTensorToPyObjectNoSync managed_tensor_to_py_object_no_sync;
658666
/*!

0 commit comments

Comments
 (0)