Skip to content

Commit cef078e

Browse files
committed
Fix notes and device type override
1 parent c657749 commit cef078e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

spec/API_specification/signatures/array_object.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from ._types import array, dtype, device, Optional, Tuple, Union, Any, PyCapsule, Enum, ellipsis
1+
from ._types import array, dtype, Optional, Tuple, Union, Any, PyCapsule, Enum, ellipsis
2+
from ._types import device as Device
23

34
class array():
45
def __init__(self) -> None:
@@ -18,7 +19,7 @@ def dtype() -> dtype:
1819
"""
1920

2021
@property
21-
def device() -> device:
22+
def device() -> Device:
2223
"""
2324
Hardware device the array data resides on.
2425
@@ -244,13 +245,25 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P
244245
245246
For other device types which do have a stream, queue or similar synchronization mechanism, the most appropriate type to use for `stream` is not yet determined. E.g., for SYCL one may want to use an object containing an in-order ``cl::sycl::queue``. This is allowed when libraries agree on such a convention, and may be standardized in a future version of this API standard.
246247
247-
**Note**
248+
**Tip**
248249
249-
Support for a ``stream`` value other than ``None`` is optional and implementation-dependent.
250+
It is recommended that implementers explicitly handle streams. If
251+
they use the legacy default stream, specifying ``1`` (CUDA) or ``0``
252+
(ROCm) is preferred. ``None`` is a safe default for developers who do
253+
not want to think about stream handling at all, potentially at the
254+
cost of more synchronization than necessary.
250255
251-
Device-specific notes:
256+
Returns
257+
-------
258+
capsule: PyCapsule
259+
a DLPack capsule for the array. See :ref:`data-interchange` for details.
260+
261+
Notes
262+
-----
263+
- Support for a ``stream`` value other than ``None`` is optional and implementation-dependent.
264+
- Device-specific notes:
252265
253-
**CUDA**
266+
**CUDA**
254267
255268
- ``None``: producer must assume the legacy default stream (default).
256269
- ``1``: the legacy default stream.
@@ -259,26 +272,13 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P
259272
260273
``0`` is disallowed due to its ambiguity: ``0`` could mean either ``None``, ``1``, or ``2``.
261274
262-
**ROCm**
275+
**ROCm**
263276
264277
- ``None``: producer must assume the legacy default stream (default).
265278
- ``0``: the default stream.
266279
- ``> 2``: stream number represented as a Python integer.
267280
268281
Using ``1`` and ``2`` is not supported.
269-
270-
**Tip**
271-
272-
It is recommended that implementers explicitly handle streams. If
273-
they use the legacy default stream, specifying ``1`` (CUDA) or ``0``
274-
(ROCm) is preferred. ``None`` is a safe default for developers who do
275-
not want to think about stream handling at all, potentially at the
276-
cost of more synchronization than necessary.
277-
278-
Returns
279-
-------
280-
capsule: PyCapsule
281-
a DLPack capsule for the array. See :ref:`data-interchange` for details.
282282
"""
283283

284284
def __dlpack_device__(self: array, /) -> Tuple[Enum, int]:
@@ -925,7 +925,7 @@ def __xor__(self: array, other: Union[int, bool, array], /) -> array:
925925
- Element-wise results must equal the results returned by the equivalent element-wise function :ref:`function-bitwise_xor`.
926926
"""
927927

928-
def to_device(self: array, device: device, /, *, stream: Optional[Union[int, Any]] = None) -> array:
928+
def to_device(self: array, device: Device, /, *, stream: Optional[Union[int, Any]] = None) -> array:
929929
"""
930930
Copy the array from the device on which it currently resides to the specified ``device``.
931931

0 commit comments

Comments
 (0)