Slice - 1 vs 11#
Next section compares an older to a newer version of the same operator after both definition are converted into markdown text. Green means an addition to the newer version, red means a deletion. Anything else is unchanged.
- Slice1 → Slice11 +16 -29
Slice1 → Slice11
RENAMED
@@ -1 +1 @@
|
|
1
1
|
Produces a slice of the input tensor along multiple axes. Similar to numpy:
|
2
2
|
https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
|
3
|
-
Slices uses
|
3
|
+
Slices uses axes, starts and ends attributes to specify the start and end
|
4
|
-
dimension
|
4
|
+
dimension for each axis in the list of axes, it uses this information to
|
5
5
|
slice the input data tensor. If a negative value is passed for any of the
|
6
|
-
start or end indices, it
|
6
|
+
start or end indices, it represent number of elements before the end of that
|
7
7
|
dimension. If the value passed to start or end is larger than the n (the
|
8
8
|
number of elements in this dimension), it represents n. For slicing to the
|
9
|
-
end of a dimension with unknown size, it is recommended to pass in INT_MAX
|
9
|
+
end of a dimension with unknown size, it is recommended to pass in INT_MAX.
|
10
|
-
when slicing forward and 'INT_MIN' when slicing backward.
|
11
|
-
If a negative value is passed for step, it represents slicing backward.
|
12
|
-
However step value cannot be 0.
|
13
10
|
If axes are omitted, they are set to [0, ..., ndim-1].
|
14
|
-
If steps are omitted, they are set to [1, ..., 1] of length len(starts)
|
15
11
|
Example 1:
|
16
12
|
data = [
|
17
13
|
[1, 2, 3, 4],
|
18
14
|
[5, 6, 7, 8],
|
19
15
|
]
|
20
16
|
axes = [0, 1]
|
21
17
|
starts = [1, 0]
|
22
18
|
ends = [2, 3]
|
23
|
-
steps = [1, 2]
|
24
19
|
result = [
|
25
|
-
[5, 7],
|
20
|
+
[5, 6, 7],
|
26
21
|
]
|
27
22
|
Example 2:
|
28
23
|
data = [
|
29
24
|
[1, 2, 3, 4],
|
30
25
|
[5, 6, 7, 8],
|
31
26
|
]
|
32
27
|
starts = [0, 1]
|
33
28
|
ends = [-1, 1000]
|
34
29
|
result = [
|
35
30
|
[2, 3, 4],
|
36
31
|
]
|
32
|
+
**Attributes**
|
33
|
+
|
34
|
+
* **axes**:
|
35
|
+
Axes that starts and ends apply to. It's optional. If not
|
36
|
+
present, will be treated as [0, 1, ..., len(starts) - 1].
|
37
|
+
* **ends** (required):
|
38
|
+
Ending indices (exclusive) of corresponding axis in axes
|
39
|
+
* **starts** (required):
|
40
|
+
Starting indices of corresponding axis in axes
|
41
|
+
|
37
42
|
**Inputs**
|
38
|
-
|
39
|
-
Between 3 and 5 inputs.
|
40
43
|
* **data** (heterogeneous) - **T**:
|
41
44
|
Tensor of data to extract slices from.
|
42
|
-
* **starts** (heterogeneous) - **Tind**:
|
43
|
-
1-D tensor of starting indices of corresponding axis in axes
|
44
|
-
* **ends** (heterogeneous) - **Tind**:
|
45
|
-
1-D tensor of ending indices (exclusive) of corresponding axis in
|
46
|
-
axes
|
47
|
-
* **axes** (optional, heterogeneous) - **Tind**:
|
48
|
-
1-D tensor of axes that starts and ends apply to. Negative value
|
49
|
-
means counting dimensions from the back. Accepted range is [-r, r-1]
|
50
|
-
where r = rank(data).
|
51
|
-
* **steps** (optional, heterogeneous) - **Tind**:
|
52
|
-
1-D tensor of slice step of corresponding axis in axes. Negative
|
53
|
-
value means slicing backward. 'steps' cannot be 0. Defaults to 1.
|
54
45
|
**Outputs**
|
55
46
|
* **output** (heterogeneous) - **T**:
|
56
47
|
Sliced data tensor.
|
57
48
|
**Type Constraints**
|
58
49
|
* **T** in (
|
59
50
|
tensor(bool),
|
60
51
|
tensor(complex128),
|
61
52
|
tensor(complex64),
|
62
53
|
tensor(double),
|
63
54
|
tensor(float),
|
64
55
|
tensor(float16),
|
65
56
|
tensor(int16),
|
66
57
|
tensor(int32),
|
67
58
|
tensor(int64),
|
68
59
|
tensor(int8),
|
69
60
|
tensor(string),
|
70
61
|
tensor(uint16),
|
71
62
|
tensor(uint32),
|
72
63
|
tensor(uint64),
|
73
64
|
tensor(uint8)
|
74
65
|
):
|
75
|
-
Constrain input and output types to all tensor types
|
66
|
+
Constrain input and output types to all tensor types.- * **Tind** in (
|
76
|
-
tensor(int32),
|
77
|
-
tensor(int64)
|
78
|
-
):
|
79
|
-
Constrain indices to integer types
|