GatherND¶
GatherND - 13¶
版本¶
網域:
main
since_version:
13
function:
False
support_level:
SupportType.COMMON
形狀推論:
True
此運算子版本自第 13 版起可用。
摘要¶
給定秩為 r
>= 1 的 data
張量,秩為 q
>= 1 的 indices
張量,以及整數 batch_dims
b
,此運算子會將 data
的切片收集到秩為 q + r - indices_shape[-1] - 1 - b
的輸出張量中。
indices
是一個 q 維整數張量,最好將其視為一個 (q-1)
維張量,其中包含指向 data
的索引元組,其中每個元素定義 data
的一個切片。
batch_dims
(表示為 b
) 是一個整數,表示批次維度的數量,即 data
張量和 indices
的前導 b
個維度代表批次,而收集從第 b+1
個維度開始。
關於輸入的秩和形狀的一些重點
必須遵守 r >= 1 和 q >= 1。秩
r
和q
之間沒有必須滿足的相依性條件indices
張量和data
張量的形狀的前b
個維度必須相等。必須遵守 b < min(q, r)。
indices_shape[-1]
的值應該介於 1 (含) 和秩r-b
(含) 之間indices
中的所有值都應在大小為s
的軸上的範圍 [-s, s-1] 內(即)-data_shape[i] <= indices[...,i] <= data_shape[i] - 1
。如果任何索引值超出範圍,則會發生錯誤。
輸出計算方式如下
輸出張量是透過將 indices
張量中的每個索引元組對應到輸入 data
的對應切片來獲得。
如果
indices_shape[-1] > r-b
=> 錯誤狀況如果
indices_shape[-1] == r-b
,由於indices
的秩為q
,因此可以將indices
視為包含維度為r-b
的 1 維張量的N
個(q-b-1)
維張量,其中N
是一個等於 1 和 indices_shape 的批次維度中所有元素的乘積的整數。讓我們將每個這種秩為r-b
的張量視為indices_slice
。對應於data[0:b-1,indices_slice]
的每個純量值都會填入(q-b-1)
維張量的對應位置,以形成output
張量(如下面的範例 1)。如果
indices_shape[-1] < r-b
,由於indices
的秩為q
,因此可以將indices
視為包含維度為< r-b
的 1 維張量的N
個(q-b-1)
維張量。讓我們將每個這樣的張量視為indices_slice
。對應於data[0:b-1, indices_slice , :]
的每個張量切片都會填入(q-b-1)
維張量的對應位置,以形成output
張量(如下面的範例 2、3、4 和 5)。
此運算子是 ScatterND
的反向運算子。
範例 1
batch_dims = 0
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[0,0],[1,1]] # indices_shape = [2, 2]
output = [0,3] # output_shape = [2]
範例 2
batch_dims = 0
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[1],[0]] # indices_shape = [2, 1]
output = [[2,3],[0,1]] # output_shape = [2, 2]
範例 3
batch_dims = 0
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[0,1],[1,0]] # indices_shape = [2, 2]
output = [[2,3],[4,5]] # output_shape = [2, 2]
範例 4
batch_dims = 0
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]
output = [[[2,3]],[[4,5]]] # output_shape = [2, 1, 2]
範例 5
batch_dims = 1
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[1],[0]] # indices_shape = [2, 1]
output = [[2,3],[4,5]] # output_shape = [2, 2]
屬性¶
batch_dims - INT (預設值為
'0'
)批次維度的數量。索引的收集從 data[batch_dims:] 的維度開始
輸入¶
data (異質) - T
秩 r >= 1 的張量。
indices (異質) - tensor(int64)
秩 q >= 1 的張量。所有索引值都應在大小為 s 的軸上的範圍 [-s, s-1] 內。如果任何索引值超出範圍,則會發生錯誤。
輸出¶
output (異質) - T
秩為 q + r - indices_shape[-1] - 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)
)將輸入和輸出型別約束為任何張量型別。
GatherND - 12¶
版本¶
網域:
main
since_version:
12
function:
False
support_level:
SupportType.COMMON
形狀推論:
True
此運算子版本自第 12 版起可用。
摘要¶
給定秩為 r
>= 1 的 data
張量,秩為 q
>= 1 的 indices
張量,以及整數 batch_dims
b
,此運算子會將 data
的切片收集到秩為 q + r - indices_shape[-1] - 1 - b
的輸出張量中。
indices
是一個 q 維整數張量,最好將其視為一個 (q-1)
維張量,其中包含指向 data
的索引元組,其中每個元素定義 data
的一個切片。
batch_dims
(表示為 b
) 是一個整數,表示批次維度的數量,即 data
張量和 indices
的前導 b
個維度代表批次,而收集從第 b+1
個維度開始。
關於輸入的秩和形狀的一些重點
必須遵守 r >= 1 和 q >= 1。秩
r
和q
之間沒有必須滿足的相依性條件indices
張量和data
張量的形狀的前b
個維度必須相等。必須遵守 b < min(q, r)。
indices_shape[-1]
的值應該介於 1 (含) 和秩r-b
(含) 之間indices
中的所有值都應在大小為s
的軸上的範圍 [-s, s-1] 內(即)-data_shape[i] <= indices[...,i] <= data_shape[i] - 1
。如果任何索引值超出範圍,則會發生錯誤。
輸出計算方式如下
輸出張量是透過將 indices
張量中的每個索引元組對應到輸入 data
的對應切片來獲得。
如果
indices_shape[-1] > r-b
=> 錯誤狀況如果
indices_shape[-1] == r-b
,由於indices
的秩為q
,因此可以將indices
視為包含維度為r-b
的 1 維張量的N
個(q-b-1)
維張量,其中N
是一個等於 1 和 indices_shape 的批次維度中所有元素的乘積的整數。讓我們將每個這種秩為r-b
的張量視為indices_slice
。對應於data[0:b-1,indices_slice]
的每個純量值都會填入(q-b-1)
維張量的對應位置,以形成output
張量(如下面的範例 1)。如果
indices_shape[-1] < r-b
,由於indices
的秩為q
,因此可以將indices
視為包含維度為< r-b
的 1 維張量的N
個(q-b-1)
維張量。讓我們將每個這樣的張量視為indices_slice
。對應於data[0:b-1, indices_slice , :]
的每個張量切片都會填入(q-b-1)
維張量的對應位置,以形成output
張量(如下面的範例 2、3、4 和 5)。
此運算子是 ScatterND
的反向運算子。
範例 1
batch_dims = 0
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[0,0],[1,1]] # indices_shape = [2, 2]
output = [0,3] # output_shape = [2]
範例 2
batch_dims = 0
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[1],[0]] # indices_shape = [2, 1]
output = [[2,3],[0,1]] # output_shape = [2, 2]
範例 3
batch_dims = 0
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[0,1],[1,0]] # indices_shape = [2, 2]
output = [[2,3],[4,5]] # output_shape = [2, 2]
範例 4
batch_dims = 0
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]
output = [[[2,3]],[[4,5]]] # output_shape = [2, 1, 2]
範例 5
batch_dims = 1
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[1],[0]] # indices_shape = [2, 1]
output = [[2,3],[4,5]] # output_shape = [2, 2]
屬性¶
batch_dims - INT (預設值為
'0'
)批次維度的數量。索引的收集從 data[batch_dims:] 的維度開始
輸入¶
data (異質) - T
秩 r >= 1 的張量。
indices (異質) - tensor(int64)
秩 q >= 1 的張量。所有索引值都應在大小為 s 的軸上的範圍 [-s, s-1] 內。如果任何索引值超出範圍,則會發生錯誤。
輸出¶
output (異質) - T
秩為 q + r - indices_shape[-1] - 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)
)將輸入和輸出型別約束為任何張量型別。
GatherND - 11¶
版本¶
網域:
main
since_version:
11
function:
False
support_level:
SupportType.COMMON
形狀推論:
True
此運算子的版本自版本 11 起可用。
摘要¶
給定秩 (rank) r
>= 1 的 data
張量,以及秩 (rank) q
>= 1 的 indices
張量,此運算子將 data
的切片收集到秩 (rank) 為 q + r - indices_shape[-1] - 1
的輸出張量中。
indices
是一個 q 維整數張量,最好將其視為一個 (q-1)
維張量,其中包含指向 data
的索引元組,其中每個元素定義 data
的一個切片。
關於輸入的秩和形狀的一些重點
必須遵守 r >= 1 和 q >= 1。秩
r
和q
之間沒有必須滿足的相依性條件indices_shape[-1]
的值應介於 1 (含) 和秩 (rank)r
(含) 之間indices
中的所有值都應在大小為s
的軸上的範圍 [-s, s-1] 內(即)-data_shape[i] <= indices[...,i] <= data_shape[i] - 1
。如果任何索引值超出範圍,則會發生錯誤。
輸出計算方式如下
輸出張量是透過將 indices
張量中的每個索引元組對應到輸入 data
的對應切片來獲得。
若
indices_shape[-1] > r
=> 錯誤情況若
indices_shape[-1] == r
,由於indices
的秩 (rank) 為q
,因此可以將indices
視為一個包含維度為r
的 1 維張量的(q-1)
維張量。讓我們將每個這樣的秩 (rank) 為r
的張量視為indices_slice
。對應於data[indices_slice]
的每個純量值都會填入(q-1)
維張量的對應位置,以形成output
張量 (以下範例 1)。若
indices_shape[-1] < r
,由於indices
的秩 (rank) 為q
,因此可以將indices
視為一個包含維度為< r
的 1 維張量的(q-1)
維張量。讓我們將每個這樣的張量視為indices_slice
。對應於data[indices_slice , :]
的每個張量切片都會填入(q-1)
維張量的對應位置,以形成output
張量 (以下範例 2、3 和 4)。
此運算子是 ScatterND
的反向運算子。
範例 1
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[0,0],[1,1]] # indices_shape = [2, 2]
output = [0,3] # output_shape = [2]
範例 2
data = [[0,1],[2,3]] # data_shape = [2, 2]
indices = [[1],[0]] # indices_shape = [2, 1]
output = [[2,3],[0,1]] # output_shape = [2, 2]
範例 3
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[0,1],[1,0]] # indices_shape = [2, 2]
output = [[2,3],[4,5]] # output_shape = [2, 2]
範例 4
data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2]
indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]
output = [[[2,3]],[[4,5]]] # output_shape = [2, 1, 2]
輸入¶
data (異質) - T
秩 r >= 1 的張量。
indices (異質) - tensor(int64)
秩 q >= 1 的張量。所有索引值都應在大小為 s 的軸上的範圍 [-s, s-1] 內。如果任何索引值超出範圍,則會發生錯誤。
輸出¶
output (異質) - T
秩為 q + r - indices_shape[-1] - 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)
)將輸入和輸出型別約束為任何張量型別。