Skip to content

Commit 8b127fc

Browse files
committed
✨ HasDevice
Signed-off-by: nstarman <[email protected]>
1 parent 930abe8 commit 8b127fc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,20 @@ def dtype(self) -> DType_co:
6262
...
6363

6464

65+
class HasDevice(Protocol):
66+
"""Protocol for array classes that have a device attribute."""
67+
68+
@property
69+
def device(self) -> object: # TODO: more specific type
70+
"""Hardware device the array data resides on."""
71+
...
72+
73+
6574
@docstring_setter(**_array_docstrings)
6675
class Array(
6776
# ------ Attributes -------
6877
HasDType[DType_co],
78+
HasDevice,
6979
# ------ Methods -------
7080
HasArrayNamespace[NS_co],
7181
op.CanPosSelf,

0 commit comments

Comments
 (0)