You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/API_specification/signatures/array_object.py
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,8 @@ def __init__(self) -> None:
6
6
Initialize the attributes for the array object class.
7
7
"""
8
8
9
-
self.dtype=None
9
+
@property
10
+
defdtype() ->dtype:
10
11
"""
11
12
Data type of the array elements.
12
13
@@ -16,7 +17,8 @@ def __init__(self) -> None:
16
17
array data type.
17
18
"""
18
19
19
-
self.device=None
20
+
@property
21
+
defdevice() ->device:
20
22
"""
21
23
Hardware device the array data resides on.
22
24
@@ -26,7 +28,8 @@ def __init__(self) -> None:
26
28
a ``device`` object (see :ref:`device-support`).
27
29
"""
28
30
29
-
self.mT=None
31
+
@property
32
+
defmT() ->array:
30
33
"""
31
34
Transpose of a matrix (or a stack of matrices).
32
35
@@ -38,7 +41,8 @@ def __init__(self) -> None:
38
41
array whose last two dimensions (axes) are permuted in reverse order relative to original array (i.e., for an array instance having shape ``(..., M, N)``, the returned array must have shape ``(..., N, M)``). The returned array must have the same data type as the original array.
39
42
"""
40
43
41
-
self.ndim=None
44
+
@property
45
+
defndim() ->int:
42
46
"""
43
47
Number of array dimensions (axes).
44
48
@@ -48,7 +52,8 @@ def __init__(self) -> None:
48
52
number of array dimensions (axes).
49
53
"""
50
54
51
-
self.shape=None
55
+
@property
56
+
defshape() ->Tuple[Optional[int], ...]:
52
57
"""
53
58
Array dimensions.
54
59
@@ -64,7 +69,8 @@ def __init__(self) -> None:
64
69
- The returned value should be a tuple; however, where warranted, an array library may choose to return a custom shape object. If an array library returns a custom shape object, the object must be immutable, must support indexing for dimension retrieval, and must behave similarly to a tuple.
65
70
"""
66
71
67
-
self.size=None
72
+
@property
73
+
defsize() ->Optional[int]:
68
74
"""
69
75
Number of elements in an array.
70
76
@@ -80,7 +86,8 @@ def __init__(self) -> None:
80
86
- For array libraries having graph-based computational models, an array may have unknown dimensions due to data-dependent operations.
- If ``stream`` is given, the copy operation should be enqueued on the provided ``stream``; otherwise, the copy operation should be enqueued on the default stream/queue. Whether the copy is performed synchronously or asynchronously is implementation-dependent. Accordingly, if synchronization is required to guarantee data safety, this must be clearly explained in a conforming library's documentation.
0 commit comments