GatherND

GatherND - 13

版本

  • 名称: GatherND (GitHub)

  • : main

  • 起始版本: 13

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

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

摘要

给定秩为 r >= 1 的 data 张量,秩为 q >= 1 的 indices 张量,以及整数 bbatch_dims),此运算符将 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. 沿大小为 s 的轴,indices 中的所有值应在范围 [-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 的秩为 q,因此 indices 可以被认为是 N(q-b-1) 维张量,其中包含维度为 r-b 的 1 维张量,其中 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 的秩为 q,因此 indices 可以被认为是 N(q-b-1) 维张量,其中包含维度 < r-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 (异构) - 张量(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

  • 起始版本: 12

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

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

摘要

给定秩为 r >= 1 的 data 张量,秩为 q >= 1 的 indices 张量,以及整数 bbatch_dims),此运算符将 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. 沿大小为 s 的轴,indices 中的所有值应在范围 [-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 的秩为 q,因此 indices 可以被认为是 N(q-b-1) 维张量,其中包含维度为 r-b 的 1 维张量,其中 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 的秩为 q,因此 indices 可以被认为是 N(q-b-1) 维张量,其中包含维度 < r-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 (异构) - 张量(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

  • 起始版本: 11

  • 函数: False

  • 支持级别: 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. 沿大小为 s 的轴,indices 中的所有值应在范围 [-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 的秩为 q,因此 indices 可以被认为是 (q-1) 维张量,其中包含维度为 r 的 1 维张量。让我们将每个这样的 r 秩张量视为 indices_slice。将与 data[indices_slice] 对应的每个*标量值*填充到 (q-1) 维张量的相应位置,以形成 output 张量(参见下面的示例 1)

  3. 如果 indices_shape[-1] < r,由于 indices 的秩为 q,因此 indices 可以被认为是 (q-1) 维张量,其中包含维度 < r 的 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 (异构) - 张量(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) )

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