ScatterElements - 13 vs 16¶
ScatterElements13 → ScatterElements16
RENAMED
@@ -1 +1 @@
|
|
1
1
|
ScatterElements takes three inputs data, updates, and indices of the same
|
2
2
|
rank r >= 1 and an optional attribute axis that identifies an axis of data
|
3
3
|
(by default, the outer-most axis, that is axis 0). The output of the operation
|
4
4
|
is produced by creating a copy of the input data, and then updating its value
|
5
5
|
to values specified by updates at specific index positions specified by
|
6
6
|
indices. Its output shape is the same as the shape of data.
|
7
|
-
|
8
7
|
For each entry in updates, the target index in data is obtained by combining
|
9
8
|
the corresponding entry in indices with the index of the entry itself: the
|
10
9
|
index-value for dimension = axis is obtained from the value of the corresponding
|
11
10
|
entry in indices and the index-value for dimension != axis is obtained from the
|
12
11
|
index of the entry itself.
|
13
|
-
|
12
|
+
reduction allows specification of an optional reduction operation, which is applied to all values in updates
|
13
|
+
tensor into output at the specified indices.
|
14
|
+
In cases where reduction is set to "none", indices should not have duplicate entries: that is, if idx1 != idx2,
|
14
|
-
For instance, in a 2-D tensor case, the update
|
15
|
+
then indices[idx1] != indices[idx2]. For instance, in a 2-D tensor case, the update
|
15
|
-
is performed as below:
|
16
|
+
corresponding to the [i][j] entry is performed as below:
|
16
17
|
::
|
17
18
|
output[indices[i][j]][j] = updates[i][j] if axis = 0,
|
18
19
|
output[i][indices[i][j]] = updates[i][j] if axis = 1,
|
20
|
+
When reduction is set to "add", the update corresponding to the [i][j] entry is performed as below:
|
21
|
+
::
|
22
|
+
|
23
|
+
output[indices[i][j]][j] += updates[i][j] if axis = 0,
|
24
|
+
output[i][indices[i][j]] += updates[i][j] if axis = 1,
|
25
|
+
|
26
|
+
When reduction is set to "mul", the update corresponding to the [i][j] entry is performed as below:
|
27
|
+
::
|
28
|
+
|
29
|
+
output[indices[i][j]][j] *= updates[i][j] if axis = 0,
|
30
|
+
output[i][indices[i][j]] *= updates[i][j] if axis = 1,
|
31
|
+
|
19
32
|
This operator is the inverse of GatherElements. It is similar to Torch's Scatter operation.
|
20
|
-
|
21
33
|
Example 1:
|
22
34
|
::
|
23
35
|
data = [
|
24
36
|
[0.0, 0.0, 0.0],
|
25
37
|
[0.0, 0.0, 0.0],
|
26
38
|
[0.0, 0.0, 0.0],
|
27
39
|
]
|
28
40
|
indices = [
|
29
41
|
[1, 0, 2],
|
30
42
|
[0, 2, 1],
|
31
43
|
]
|
32
44
|
updates = [
|
33
45
|
[1.0, 1.1, 1.2],
|
34
46
|
[2.0, 2.1, 2.2],
|
35
47
|
]
|
36
48
|
output = [
|
37
49
|
[2.0, 1.1, 0.0]
|
38
50
|
[1.0, 0.0, 2.2]
|
39
51
|
[0.0, 2.1, 1.2]
|
40
52
|
]
|
41
53
|
Example 2:
|
42
54
|
::
|
43
55
|
data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
|
44
56
|
indices = [[1, 3]]
|
45
57
|
updates = [[1.1, 2.1]]
|
46
58
|
axis = 1
|
47
59
|
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]
|
48
60
|
**Attributes**
|
49
61
|
* **axis**:
|
50
62
|
Which axis to scatter on. Negative value means counting dimensions
|
51
63
|
from the back. Accepted range is [-r, r-1] where r = rank(data).
|
64
|
+
* **reduction**:
|
65
|
+
Type of reduction to apply: none (default), add, mul. 'none': no
|
66
|
+
reduction applied. 'add': reduction using the addition operation.
|
67
|
+
'mul': reduction using the multiplication operation.
|
52
68
|
**Inputs**
|
53
69
|
* **data** (heterogeneous) - **T**:
|
54
70
|
Tensor of rank r >= 1.
|
55
71
|
* **indices** (heterogeneous) - **Tind**:
|
56
72
|
Tensor of int32/int64 indices, of r >= 1 (same rank as input). All
|
57
73
|
index values are expected to be within bounds [-s, s-1] along axis
|
58
74
|
of size s. It is an error if any of the index values are out of
|
59
75
|
bounds.
|
60
76
|
* **updates** (heterogeneous) - **T**:
|
61
77
|
Tensor of rank r >=1 (same rank and shape as indices)
|
62
78
|
**Outputs**
|
63
79
|
* **output** (heterogeneous) - **T**:
|
64
80
|
Tensor of rank r >= 1 (same rank as input).
|
65
81
|
**Type Constraints**
|
66
82
|
* **T** in (
|
67
83
|
tensor(bfloat16),
|
68
84
|
tensor(bool),
|
69
85
|
tensor(complex128),
|
70
86
|
tensor(complex64),
|
71
87
|
tensor(double),
|
72
88
|
tensor(float),
|
73
89
|
tensor(float16),
|
74
90
|
tensor(int16),
|
75
91
|
tensor(int32),
|
76
92
|
tensor(int64),
|
77
93
|
tensor(int8),
|
78
94
|
tensor(string),
|
79
95
|
tensor(uint16),
|
80
96
|
tensor(uint32),
|
81
97
|
tensor(uint64),
|
82
98
|
tensor(uint8)
|
83
99
|
):
|
84
100
|
Input and output types can be of any tensor type.
|
85
101
|
* **Tind** in (
|
86
102
|
tensor(int32),
|
87
103
|
tensor(int64)
|
88
104
|
):
|
89
105
|
Constrain indices to integer types
|