Skip to content

Commit 3741de7

Browse files
committed
✨ HasDevice
Signed-off-by: nstarman <[email protected]>
1 parent b2dca8e commit 3741de7

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
@@ -67,9 +67,19 @@ def dtype(self, /) -> DTypeT_co:
6767
...
6868

6969

70+
class HasDevice(Protocol):
71+
"""Protocol for array classes that have a device attribute."""
72+
73+
@property
74+
def device(self) -> object: # TODO: more specific type
75+
"""Hardware device the array data resides on."""
76+
...
77+
78+
7079
class Array(
7180
# ------ Attributes -------
7281
HasDType[DTypeT_co],
82+
HasDevice,
7383
# ------- Methods ---------
7484
HasArrayNamespace[NamespaceT_co],
7585
# -------------------------

0 commit comments

Comments
 (0)