GatherND

GatherND - 13

版本

  • 名称: GatherND (GitHub)

  • 域名: main

  • since_version: 13

  • 函数: 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 维度开始。

关于输入数据的秩和形状的一些显著要点:

  1. r >= 1 和 q >= 1 需要被遵守。在等级 rq 之间没有需要满足的依赖条件。

  2. indices 张量和 data 张量的形状的前 b 个维度必须相等。

  3. b < min(q, r) 需要被遵守。

  4. indices_shape[-1] 的值应在1(包括)和秩 r-b(包括)之间

  5. indices 中的所有值都应在大小为 s 的轴上的边界 [-s, s-1] 内(即 -data_shape[i] <= indices[...,i] <= data_shape[i] - 1)。 如果任何索引值超出边界,则会出现错误。

输出计算如下:

输出张量是通过将indices张量中的每个索引元组映射到输入data的相应切片来获得的。

  1. 如果 indices_shape[-1] > r-b => 错误条件

  2. 如果 indices_shape[-1] == r-b,由于 indices 的秩是 qindices 可以被视为 N(q-b-1) 维的张量,包含维度为 r-b 的一维张量,其中 N 是一个整数,等于 1 和 indices_shape 的批次维度中所有元素的乘积。让我们将每个这样的 r-b 秩张量视为 indices_slice。每个对应于 data[0:b-1,indices_slice]标量值被填充到 (q-b-1) 维张量的相应位置,以形成 output 张量(如下例 1 所示)

  3. 如果 indices_shape[-1] < r-b,由于 indices 的秩是 qindices 可以被视为 N(q-b-1) 维的张量,包含维度为 < r-b 的一维张量。让我们将每个这样的张量视为 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] 内。如果任何索引值超出边界,则会出现错误。

输出

  • 输出 (异构) - T:

    秩为 q + r - indices_shape[-1] - 1 的张量。

类型约束

  • T 在 ( 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

版本

  • 名称: GatherND (GitHub)

  • 域名: main

  • since_version: 12

  • 函数: 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 维度开始。

关于输入数据的秩和形状的一些显著要点:

  1. r >= 1 和 q >= 1 需要被遵守。在等级 rq 之间没有需要满足的依赖条件。

  2. indices 张量和 data 张量的形状的前 b 个维度必须相等。

  3. b < min(q, r) 需要被遵守。

  4. indices_shape[-1] 的值应在1(包括)和秩 r-b(包括)之间

  5. indices 中的所有值都应在大小为 s 的轴上的边界 [-s, s-1] 内(即 -data_shape[i] <= indices[...,i] <= data_shape[i] - 1)。 如果任何索引值超出边界,则会出现错误。

输出计算如下:

输出张量是通过将indices张量中的每个索引元组映射到输入data的相应切片来获得的。

  1. 如果 indices_shape[-1] > r-b => 错误条件

  2. 如果 indices_shape[-1] == r-b,由于 indices 的秩是 qindices 可以被视为 N(q-b-1) 维的张量,包含维度为 r-b 的一维张量,其中 N 是一个整数,等于 1 和 indices_shape 的批次维度中所有元素的乘积。让我们将每个这样的 r-b 秩张量视为 indices_slice。每个对应于 data[0:b-1,indices_slice]标量值被填充到 (q-b-1) 维张量的相应位置,以形成 output 张量(如下例 1 所示)

  3. 如果 indices_shape[-1] < r-b,由于 indices 的秩是 qindices 可以被视为 N(q-b-1) 维的张量,包含维度为 < r-b 的一维张量。让我们将每个这样的张量视为 indices_slice。每个对应于 data[0:b-1, indices_slice , :]张量切片 被填充到 (q-b-1) 维张量的相应位置,以形成 output 张量(下面的示例 2、3、4 和 5)

此操作符是ScatterND的逆操作。

示例 1

batch_dims = 0

数据 = [[0,1],[2,3]] # 数据形状 = [2, 2]

indices = [[0,0],[1,1]] # indices_shape = [2, 2]

输出 = [0,3] # 输出形状 = [2]

示例 2

batch_dims = 0

data = [[0,1],[2,3]] # 数据形状 = [2, 2]

indices = [[1],[0]] # indices_shape = [2, 1]

输出 = [[2,3],[0,1]] # 输出形状 = [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]

输出 = [[2,3],[4,5]] # 输出形状 = [2, 2]

示例 4

batch_dims = 0

数据 = [[[0,1],[2,3]],[[4,5],[6,7]]] # 数据形状 = [2, 2, 2]

indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]

输出 = [[[2,3]],[[4,5]]] # 输出形状 = [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]

输出 = [[2,3],[4,5]] # 输出形状 = [2, 2]

属性

  • batch_dims - INT (默认值为 '0'):

    批处理维度的数量。索引的收集从数据的维度 data[batch_dims:] 开始。

输入

  • data (异构) - T:

    秩为 r >= 1 的张量。

  • indices (异构) - tensor(int64):

    秩为 q >= 1 的张量。所有索引值都应在大小为 s 的轴上位于边界 [-s, s-1] 内。如果任何索引值超出边界,则会出现错误。

输出

  • 输出 (异构) - T:

    秩为 q + r - indices_shape[-1] - 1 的张量。

类型约束

  • T 在 ( 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

版本

  • 名称: GatherND (GitHub)

  • 域名: main

  • since_version: 11

  • 函数: False

  • support_level: SupportType.COMMON

  • 形状推断: True

此版本的运算符自版本11起可用。

总结

给定秩为 r >= 1 的 data 张量,以及秩为 q >= 1 的 indices 张量,该操作符将 data 的切片收集到秩为 q + r - indices_shape[-1] - 1 的输出张量中。

indices 是一个 q 维的整数张量,最好将其视为一个 (q-1) 维的索引元组张量,指向 data, 其中每个元素定义了 data 的一个切片

关于输入数据的秩和形状的一些显著要点:

  1. r >= 1 和 q >= 1 需要被遵守。在等级 rq 之间没有需要满足的依赖条件。

  2. indices_shape[-1] 的值应在 1(包括)和秩 r(包括)之间

  3. indices 中的所有值都应在大小为 s 的轴上的边界 [-s, s-1] 内(即 -data_shape[i] <= indices[...,i] <= data_shape[i] - 1)。 如果任何索引值超出边界,则会出现错误。

输出计算如下:

输出张量是通过将indices张量中的每个索引元组映射到输入data的相应切片来获得的。

  1. 如果 indices_shape[-1] > r => 错误条件

  2. 如果 indices_shape[-1] == r,由于 indices 的秩是 qindices 可以被视为一个 (q-1) 维的张量,包含维度为 r 的一维张量。让我们将每个这样的 r 秩张量视为 indices_slice。每个对应于 data[indices_slice]标量值被填充到 (q-1) 维张量的相应位置,以形成 output 张量(如下例1所示)

  3. 如果 indices_shape[-1] < r,由于 indices 的秩是 qindices 可以被视为一个 (q-1) 维的张量,包含维度为 < r 的一维张量。让我们将每个这样的张量视为 indices_slice。每个对应于 data[indices_slice , :]张量切片被填充到 (q-1) 维张量的相应位置,以形成 output 张量(下面的示例 2、3 和 4)

此操作符是ScatterND的逆操作。

示例 1

数据 = [[0,1],[2,3]] # 数据形状 = [2, 2]

indices = [[0,0],[1,1]] # indices_shape = [2, 2]

输出 = [0,3] # 输出形状 = [2]

示例 2

data = [[0,1],[2,3]] # 数据形状 = [2, 2]

indices = [[1],[0]] # indices_shape = [2, 1]

输出 = [[2,3],[0,1]] # 输出形状 = [2, 2]

示例 3

数据 = [[[0,1],[2,3]],[[4,5],[6,7]]] # 数据形状 = [2, 2, 2]

indices = [[0,1],[1,0]] # indices_shape = [2, 2]

输出 = [[2,3],[4,5]] # 输出形状 = [2, 2]

示例 4

数据 = [[[0,1],[2,3]],[[4,5],[6,7]]] # 数据形状 = [2, 2, 2]

indices = [[[0,1]],[[1,0]]] # indices_shape = [2, 1, 2]

输出 = [[[2,3]],[[4,5]]] # 输出形状 = [2, 1, 2]

输入

  • data (异构) - T:

    秩为 r >= 1 的张量。

  • indices (异构) - tensor(int64):

    秩为 q >= 1 的张量。所有索引值都应在大小为 s 的轴上位于边界 [-s, s-1] 内。如果任何索引值超出边界,则会出现错误。

输出

  • 输出 (异构) - T:

    秩为 q + r - indices_shape[-1] - 1 的张量。

类型约束

  • T 在 ( 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) ):

    将输入和输出类型限制为任何张量类型。