ScatterElements¶
ScatterElements - 18¶
版本¶
網域:
main
since_version:
18
函數:
False
支援等級:
SupportType.COMMON
形狀推斷:
True
此版本的運算子自第 18 版開始提供。
摘要¶
ScatterElements 採用三個輸入 data
、updates
和 indices
,這些輸入具有相同的階數 r >= 1 和一個可選屬性軸,用於識別 data
的軸 (預設情況下,為最外層的軸,即軸 0)。運算的輸出是透過建立輸入 data
的副本,然後將其值更新為 updates
所指定的值,並在 indices
指定的特定索引位置產生。其輸出形狀與 data
的形狀相同。
對於 updates
中的每個項目,data
中的目標索引是透過將 indices
中對應的項目與項目本身的索引結合來獲得的:維度 = 軸的索引值是從 indices
中對應項目的值獲得,而維度 != 軸的索引值是從項目本身的索引獲得。
reduction
允許指定一個可選的簡化運算,該運算將應用於 updates
張量中的所有值,並輸入到指定 indices
的 output
中。在 reduction
設定為「none」的情況下,索引不應有重複的項目:也就是說,如果 idx1 != idx2,則 indices[idx1] != indices[idx2]。例如,在 2 維張量的情況下,對應於 [i][j] 項目的更新執行如下
output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,
當 reduction
設定為某個簡化函數 f
時,對應於 [i][j] 項目的更新執行如下
output[indices[i][j]][j] = f(output[indices[i][j]][j], updates[i][j]) if axis = 0,
output[i][indices[i][j]] = f(output[i][indices[i][j]], updates[i][j]) if axis = 1,
其中,f
是 +
、*
、max
或 min
,如指定所示。
此運算子與 GatherElements 的作用相反。它與 Torch 的 Scatter 運算相似。
(Opset 18 變更):將 max/min 加入至允許的簡化運算集合。
範例 1
data = [
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
]
indices = [
[1, 0, 2],
[0, 2, 1],
]
updates = [
[1.0, 1.1, 1.2],
[2.0, 2.1, 2.2],
]
output = [
[2.0, 1.1, 0.0]
[1.0, 0.0, 2.2]
[0.0, 2.1, 1.2]
]
範例 2
data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]
屬性¶
axis - INT (預設為
'0'
)要在其上分散的軸。負值表示從後方計算維度。可接受的範圍是 [-r, r-1],其中 r = rank(data)。
reduction - STRING (預設為
'none'
)要套用的簡化類型:none (預設值)、add、mul、max、min。 'none':不套用簡化。 'add':使用加法運算進行簡化。 'mul':使用乘法運算進行簡化。'max':使用最大值運算進行簡化。'min':使用最小值運算進行簡化。
輸入¶
data (異質) - T
階數 r >= 1 的張量。
indices (異質) - Tind
int32/int64 索引的張量,階數 r >= 1 (與輸入相同的階數)。所有索引值都應在沿大小為 s 的軸的邊界 [-s, s-1] 內。如果任何索引值超出邊界,則會發生錯誤。
updates (異質) - T
階數 r >=1 的張量 (與索引具有相同的階數和形狀)
輸出¶
output (異質) - T
階數 r >= 1 的張量 (與輸入相同的階數)。
類型限制¶
T in (
tensor(bfloat16)
、tensor(bool)
、tensor(complex128)
、tensor(complex64)
、tensor(double)
、tensor(float)
、tensor(float16)
、tensor(int16)
、tensor(int32)
、tensor(int64)
、tensor(int8)
、tensor(string)
、tensor(uint16)
、tensor(uint32)
、tensor(uint64)
、tensor(uint8)
)輸入和輸出類型可以是任何張量類型。
Tind in (
tensor(int32)
、tensor(int64)
)將索引限制為整數類型
ScatterElements - 16¶
版本¶
網域:
main
since_version:
16
函數:
False
支援等級:
SupportType.COMMON
形狀推斷:
True
此運算符版本自版本 16 起可用。
摘要¶
ScatterElements 接受三個輸入 data
、updates
和 indices
,它們的階數皆為 r >= 1,以及一個可選的屬性 axis,用於識別 data
的軸(預設為最外層的軸,即軸 0)。此運算的輸出是透過建立輸入 data
的副本,然後在其由 indices
指定的特定索引位置,將其值更新為 updates
所指定的值。其輸出形狀與 data
的形狀相同。對於 updates
中的每個條目,data
中的目標索引是透過將 indices
中相應的條目與條目本身的索引組合而獲得的:維度 = axis 的索引值是從 indices
中相應條目的值獲得,而維度 != axis 的索引值是從條目本身的索引獲得。reduction
允許指定一個可選的歸約操作,該操作將應用於 updates
張量中的所有值,並將結果歸約至 output
中指定的 indices
位置。在 reduction
設定為“none”的情況下,索引不應有重複的條目:也就是說,如果 idx1 != idx2,則 indices[idx1] != indices[idx2]。例如,在 2-D 張量的情況下,對應於 [i][j] 條目的更新執行如下:
output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,
當 reduction
設定為“add”時,對應於 [i][j] 條目的更新執行如下:
output[indices[i][j]][j] += updates[i][j] if axis = 0,
output[i][indices[i][j]] += updates[i][j] if axis = 1,
當 reduction
設定為“mul”時,對應於 [i][j] 條目的更新執行如下:
output[indices[i][j]][j] *= updates[i][j] if axis = 0,
output[i][indices[i][j]] *= updates[i][j] if axis = 1,
此運算符是 GatherElements 的反向運算符。它類似於 Torch 的 Scatter 運算。範例 1
data = [
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
]
indices = [
[1, 0, 2],
[0, 2, 1],
]
updates = [
[1.0, 1.1, 1.2],
[2.0, 2.1, 2.2],
]
output = [
[2.0, 1.1, 0.0]
[1.0, 0.0, 2.2]
[0.0, 2.1, 1.2]
]
範例 2
data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]
屬性¶
axis - INT (預設為
'0'
)要在其上分散的軸。負值表示從後方計算維度。可接受的範圍是 [-r, r-1],其中 r = rank(data)。
reduction - STRING (預設為
'none'
)要套用的歸約類型:none(預設)、add、mul。「none」:不套用歸約。「add」:使用加法運算進行歸約。「mul」:使用乘法運算進行歸約。
輸入¶
data (異質) - T
階數 r >= 1 的張量。
indices (異質) - Tind
int32/int64 索引的張量,階數 r >= 1 (與輸入相同的階數)。所有索引值都應在沿大小為 s 的軸的邊界 [-s, s-1] 內。如果任何索引值超出邊界,則會發生錯誤。
updates (異質) - T
階數 r >=1 的張量 (與索引具有相同的階數和形狀)
輸出¶
output (異質) - T
階數 r >= 1 的張量 (與輸入相同的階數)。
類型限制¶
T in (
tensor(bfloat16)
、tensor(bool)
、tensor(complex128)
、tensor(complex64)
、tensor(double)
、tensor(float)
、tensor(float16)
、tensor(int16)
、tensor(int32)
、tensor(int64)
、tensor(int8)
、tensor(string)
、tensor(uint16)
、tensor(uint32)
、tensor(uint64)
、tensor(uint8)
)輸入和輸出類型可以是任何張量類型。
Tind in (
tensor(int32)
、tensor(int64)
)將索引限制為整數類型
ScatterElements - 13¶
版本¶
網域:
main
since_version:
13
函數:
False
支援等級:
SupportType.COMMON
形狀推斷:
True
此運算符版本自版本 13 起可用。
摘要¶
ScatterElements 採用三個輸入 data
、updates
和 indices
,這些輸入具有相同的階數 r >= 1 和一個可選屬性軸,用於識別 data
的軸 (預設情況下,為最外層的軸,即軸 0)。運算的輸出是透過建立輸入 data
的副本,然後將其值更新為 updates
所指定的值,並在 indices
指定的特定索引位置產生。其輸出形狀與 data
的形狀相同。
對於 updates
中的每個項目,data
中的目標索引是透過將 indices
中對應的項目與項目本身的索引結合來獲得的:維度 = 軸的索引值是從 indices
中對應項目的值獲得,而維度 != 軸的索引值是從項目本身的索引獲得。
例如,在 2-D 張量的情況下,對應於 [i][j] 條目的更新執行如下:
output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,
此運算子與 GatherElements 的作用相反。它與 Torch 的 Scatter 運算相似。
範例 1
data = [
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
]
indices = [
[1, 0, 2],
[0, 2, 1],
]
updates = [
[1.0, 1.1, 1.2],
[2.0, 2.1, 2.2],
]
output = [
[2.0, 1.1, 0.0]
[1.0, 0.0, 2.2]
[0.0, 2.1, 1.2]
]
範例 2
data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]
屬性¶
axis - INT (預設為
'0'
)要在其上分散的軸。負值表示從後方計算維度。可接受的範圍是 [-r, r-1],其中 r = rank(data)。
輸入¶
data (異質) - T
階數 r >= 1 的張量。
indices (異質) - Tind
int32/int64 索引的張量,階數 r >= 1 (與輸入相同的階數)。所有索引值都應在沿大小為 s 的軸的邊界 [-s, s-1] 內。如果任何索引值超出邊界,則會發生錯誤。
updates (異質) - T
階數 r >=1 的張量 (與索引具有相同的階數和形狀)
輸出¶
output (異質) - T
階數 r >= 1 的張量 (與輸入相同的階數)。
類型限制¶
T in (
tensor(bfloat16)
、tensor(bool)
、tensor(complex128)
、tensor(complex64)
、tensor(double)
、tensor(float)
、tensor(float16)
、tensor(int16)
、tensor(int32)
、tensor(int64)
、tensor(int8)
、tensor(string)
、tensor(uint16)
、tensor(uint32)
、tensor(uint64)
、tensor(uint8)
)輸入和輸出類型可以是任何張量類型。
Tind in (
tensor(int32)
、tensor(int64)
)將索引限制為整數類型
ScatterElements - 11¶
版本¶
網域:
main
since_version:
11
函數:
False
支援等級:
SupportType.COMMON
形狀推斷:
True
此運算符版本自版本 11 起可用。
摘要¶
ScatterElements 採用三個輸入 data
、updates
和 indices
,這些輸入具有相同的階數 r >= 1 和一個可選屬性軸,用於識別 data
的軸 (預設情況下,為最外層的軸,即軸 0)。運算的輸出是透過建立輸入 data
的副本,然後將其值更新為 updates
所指定的值,並在 indices
指定的特定索引位置產生。其輸出形狀與 data
的形狀相同。
對於 updates
中的每個項目,data
中的目標索引是透過將 indices
中對應的項目與項目本身的索引結合來獲得的:維度 = 軸的索引值是從 indices
中對應項目的值獲得,而維度 != 軸的索引值是從項目本身的索引獲得。
例如,在 2-D 張量的情況下,對應於 [i][j] 條目的更新執行如下:
output[indices[i][j]][j] = updates[i][j] if axis = 0,
output[i][indices[i][j]] = updates[i][j] if axis = 1,
此運算子與 GatherElements 的作用相反。它與 Torch 的 Scatter 運算相似。
範例 1
data = [
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
[0.0, 0.0, 0.0],
]
indices = [
[1, 0, 2],
[0, 2, 1],
]
updates = [
[1.0, 1.1, 1.2],
[2.0, 2.1, 2.2],
]
output = [
[2.0, 1.1, 0.0]
[1.0, 0.0, 2.2]
[0.0, 2.1, 1.2]
]
範例 2
data = [[1.0, 2.0, 3.0, 4.0, 5.0]]
indices = [[1, 3]]
updates = [[1.1, 2.1]]
axis = 1
output = [[1.0, 1.1, 3.0, 2.1, 5.0]]
屬性¶
axis - INT (預設為
'0'
)要在其上分散的軸。負值表示從後方計算維度。可接受的範圍是 [-r, r-1],其中 r = rank(data)。
輸入¶
data (異質) - T
階數 r >= 1 的張量。
indices (異質) - Tind
int32/int64 索引的張量,階數 r >= 1 (與輸入相同的階數)。所有索引值都應在沿大小為 s 的軸的邊界 [-s, s-1] 內。如果任何索引值超出邊界,則會發生錯誤。
updates (異質) - T
階數 r >=1 的張量 (與索引具有相同的階數和形狀)
輸出¶
output (異質) - T
階數 r >= 1 的張量 (與輸入相同的階數)。
類型限制¶
T in (
tensor(bool)
,tensor(complex128)
,tensor(complex64)
,tensor(double)
,tensor(float)
,tensor(float16)
,tensor(int16)
,tensor(int32)
,tensor(int64)
,tensor(int8)
,tensor(string)
,tensor(uint16)
,tensor(uint32)
,tensor(uint64)
,tensor(uint8)
)輸入和輸出類型可以是任何張量類型。
Tind in (
tensor(int32)
、tensor(int64)
)將索引限制為整數類型