GatherElements - 11 vs 13¶
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
|
-
[
|
28
|
-
|
27
|
+
[1, 1],
|
29
|
-
|
28
|
+
[4, 3],
|
30
|
-
],
|
31
29
|
]
|
32
30
|
Example 2:
|
33
31
|
::
|
34
32
|
data = [
|
35
33
|
[1, 2, 3],
|
36
34
|
[4, 5, 6],
|
37
35
|
[7, 8, 9],
|
38
36
|
]
|
39
37
|
indices = [
|
40
38
|
[1, 2, 0],
|
41
39
|
[2, 0, 0],
|
42
40
|
]
|
43
41
|
axis = 0
|
44
42
|
output = [
|
45
|
-
[
|
46
|
-
|
43
|
+
[4, 8, 3],
|
47
|
-
|
44
|
+
[7, 2, 3],
|
48
|
-
],
|
49
45
|
]
|
50
46
|
**Attributes**
|
51
47
|
* **axis**:
|
52
48
|
Which axis to gather on. Negative value means counting dimensions
|
53
49
|
from the back. Accepted range is [-r, r-1] where r = rank(data).
|
54
50
|
**Inputs**
|
55
51
|
* **data** (heterogeneous) - **T**:
|
56
52
|
Tensor of rank r >= 1.
|
57
53
|
* **indices** (heterogeneous) - **Tind**:
|
58
54
|
Tensor of int32/int64 indices, with the same rank r as the input.
|
59
55
|
All index values are expected to be within bounds [-s, s-1] along
|
60
56
|
axis of size s. It is an error if any of the index values are out of
|
61
57
|
bounds.
|
62
58
|
**Outputs**
|
63
59
|
* **output** (heterogeneous) - **T**:
|
64
60
|
Tensor of the same shape as indices.
|
65
61
|
**Type Constraints**
|
66
62
|
* **T** in (
|
63
|
+
tensor(bfloat16),
|
67
64
|
tensor(bool),
|
68
65
|
tensor(complex128),
|
69
66
|
tensor(complex64),
|
70
67
|
tensor(double),
|
71
68
|
tensor(float),
|
72
69
|
tensor(float16),
|
73
70
|
tensor(int16),
|
74
71
|
tensor(int32),
|
75
72
|
tensor(int64),
|
76
73
|
tensor(int8),
|
77
74
|
tensor(string),
|
78
75
|
tensor(uint16),
|
79
76
|
tensor(uint32),
|
80
77
|
tensor(uint64),
|
81
78
|
tensor(uint8)
|
82
79
|
):
|
83
80
|
Constrain input and output types to any tensor type.
|
84
81
|
* **Tind** in (
|
85
82
|
tensor(int32),
|
86
83
|
tensor(int64)
|
87
84
|
):
|
88
85
|
Constrain indices to integer types
|