GatherElements - 11 vs 13#
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.
GatherElements11 → GatherElements13
RENAMED
@@ -1 +1 @@
|
|
1
1
|
GatherElements takes two inputs data and indices of the same rank r >= 1
|
2
2
|
and an optional attribute axis that identifies an axis of data
|
3
3
|
(by default, the outer-most axis, that is axis 0). It is an indexing operation
|
4
4
|
that produces its output by indexing into the input data tensor at index
|
5
5
|
positions determined by elements of the indices tensor.
|
6
6
|
Its output shape is the same as the shape of indices and consists of one value
|
7
7
|
(gathered from the data) for each element in indices.
|
8
8
|
For instance, in the 3-D case (r = 3), the output produced is determined
|
9
9
|
by the following equations:
|
10
10
|
::
|
11
11
|
out[i][j][k] = input[index[i][j][k]][j][k] if axis = 0,
|
12
12
|
out[i][j][k] = input[i][index[i][j][k]][k] if axis = 1,
|
13
13
|
out[i][j][k] = input[i][j][index[i][j][k]] if axis = 2,
|
14
14
|
This operator is also the inverse of ScatterElements. It is similar to Torch's gather operation.
|
15
15
|
Example 1:
|
16
16
|
::
|
17
17
|
data = [
|
18
18
|
[1, 2],
|
19
19
|
[3, 4],
|
20
20
|
]
|
21
21
|
indices = [
|
22
22
|
[0, 0],
|
23
23
|
[1, 0],
|
24
24
|
]
|
25
25
|
axis = 1
|
26
26
|
output = [
|
27
|
+
[
|
27
|
-
|
28
|
+
[1, 1],
|
28
|
-
|
29
|
+
[4, 3],
|
30
|
+
],
|
29
31
|
]
|
30
32
|
Example 2:
|
31
33
|
::
|
32
34
|
data = [
|
33
35
|
[1, 2, 3],
|
34
36
|
[4, 5, 6],
|
35
37
|
[7, 8, 9],
|
36
38
|
]
|
37
39
|
indices = [
|
38
40
|
[1, 2, 0],
|
39
41
|
[2, 0, 0],
|
40
42
|
]
|
41
43
|
axis = 0
|
42
44
|
output = [
|
45
|
+
[
|
43
|
-
|
46
|
+
[4, 8, 3],
|
44
|
-
|
47
|
+
[7, 2, 3],
|
48
|
+
],
|
45
49
|
]
|
46
50
|
**Attributes**
|
47
51
|
* **axis**:
|
48
52
|
Which axis to gather on. Negative value means counting dimensions
|
49
53
|
from the back. Accepted range is [-r, r-1] where r = rank(data).
|
50
54
|
**Inputs**
|
51
55
|
* **data** (heterogeneous) - **T**:
|
52
56
|
Tensor of rank r >= 1.
|
53
57
|
* **indices** (heterogeneous) - **Tind**:
|
54
58
|
Tensor of int32/int64 indices, with the same rank r as the input.
|
55
59
|
All index values are expected to be within bounds [-s, s-1] along
|
56
60
|
axis of size s. It is an error if any of the index values are out of
|
57
61
|
bounds.
|
58
62
|
**Outputs**
|
59
63
|
* **output** (heterogeneous) - **T**:
|
60
64
|
Tensor of the same shape as indices.
|
61
65
|
**Type Constraints**
|
62
66
|
* **T** in (
|
63
|
-
tensor(bfloat16),
|
64
67
|
tensor(bool),
|
65
68
|
tensor(complex128),
|
66
69
|
tensor(complex64),
|
67
70
|
tensor(double),
|
68
71
|
tensor(float),
|
69
72
|
tensor(float16),
|
70
73
|
tensor(int16),
|
71
74
|
tensor(int32),
|
72
75
|
tensor(int64),
|
73
76
|
tensor(int8),
|
74
77
|
tensor(string),
|
75
78
|
tensor(uint16),
|
76
79
|
tensor(uint32),
|
77
80
|
tensor(uint64),
|
78
81
|
tensor(uint8)
|
79
82
|
):
|
80
83
|
Constrain input and output types to any tensor type.
|
81
84
|
* **Tind** in (
|
82
85
|
tensor(int32),
|
83
86
|
tensor(int64)
|
84
87
|
):
|
85
88
|
Constrain indices to integer types
|