Slice - 1 vs 10#
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 → Slice10 +14 -23
Slice1 → Slice10
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
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
9
|
end of a dimension with unknown size, it is recommended to pass in INT_MAX.
|
10
|
-
If a negative value is passed for step, it represents slicing backward.
|
11
10
|
If axes are omitted, they are set to [0, ..., ndim-1].
|
12
|
-
If steps are omitted, they are set to [1, ..., 1] of length len(starts)
|
13
11
|
Example 1:
|
14
12
|
data = [
|
15
13
|
[1, 2, 3, 4],
|
16
14
|
[5, 6, 7, 8],
|
17
15
|
]
|
18
16
|
axes = [0, 1]
|
19
17
|
starts = [1, 0]
|
20
18
|
ends = [2, 3]
|
21
|
-
steps = [1, 2]
|
22
19
|
result = [
|
23
|
-
[5, 7],
|
20
|
+
[5, 6, 7],
|
24
21
|
]
|
25
22
|
Example 2:
|
26
23
|
data = [
|
27
24
|
[1, 2, 3, 4],
|
28
25
|
[5, 6, 7, 8],
|
29
26
|
]
|
30
27
|
starts = [0, 1]
|
31
28
|
ends = [-1, 1000]
|
32
29
|
result = [
|
33
30
|
[2, 3, 4],
|
34
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
|
+
|
35
42
|
**Inputs**
|
36
|
-
|
37
|
-
Between 3 and 5 inputs.
|
38
43
|
* **data** (heterogeneous) - **T**:
|
39
44
|
Tensor of data to extract slices from.
|
40
|
-
* **starts** (heterogeneous) - **Tind**:
|
41
|
-
1-D tensor of starting indices of corresponding axis in axes
|
42
|
-
* **ends** (heterogeneous) - **Tind**:
|
43
|
-
1-D tensor of ending indices (exclusive) of corresponding axis in
|
44
|
-
axes
|
45
|
-
* **axes** (optional, heterogeneous) - **Tind**:
|
46
|
-
1-D tensor of axes that starts and ends apply to.
|
47
|
-
* **steps** (optional, heterogeneous) - **Tind**:
|
48
|
-
1-D tensor of slice step of corresponding axis in axes. Default to
|
49
|
-
1.
|
50
45
|
**Outputs**
|
51
46
|
* **output** (heterogeneous) - **T**:
|
52
47
|
Sliced data tensor.
|
53
48
|
**Type Constraints**
|
54
49
|
* **T** in (
|
55
50
|
tensor(bool),
|
56
51
|
tensor(complex128),
|
57
52
|
tensor(complex64),
|
58
53
|
tensor(double),
|
59
54
|
tensor(float),
|
60
55
|
tensor(float16),
|
61
56
|
tensor(int16),
|
62
57
|
tensor(int32),
|
63
58
|
tensor(int64),
|
64
59
|
tensor(int8),
|
65
60
|
tensor(string),
|
66
61
|
tensor(uint16),
|
67
62
|
tensor(uint32),
|
68
63
|
tensor(uint64),
|
69
64
|
tensor(uint8)
|
70
65
|
):
|
71
|
-
Constrain input and output types to all tensor types
|
66
|
+
Constrain input and output types to all tensor types.- * **Tind** in (
|
72
|
-
tensor(int32),
|
73
|
-
tensor(int64)
|
74
|
-
):
|
75
|
-
Constrain indices to integer types
|