GatherND

GatherND - 版本 13

版本

  • 名称: GatherND (GitHub)

  • : main

  • 起始版本: 13

  • 函数: False

  • 支持级别: 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 的一个切片。

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 的 1-D 张量,其中 N 是一个整数,等于 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 的 1-D 张量。我们将每个这样的张量视为 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 属于 ( 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 张量以及整数 batch_dims b,此算子将 data 的切片收集到秩为 q + r - indices_shape[-1] - 1 - b 的输出张量中。

indices 是一个 q 维整数张量,最好将其视为一个 (q-1) 维的索引元组张量,其中每个元素定义了 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 的 1-D 张量,其中 N 是一个整数,等于 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 的 1-D 张量。我们将每个这样的张量视为 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 属于 ( 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 的一个切片。

关于输入张量秩和形状的一些要点

  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 的 1-D 张量。我们将每个这样的 r 秩张量视为 indices_slice。与 data[indices_slice] 对应的每个标量值被填充到 (q-1) 维张量的相应位置,以形成 output 张量(下面的示例 1)

  3. 如果 indices_shape[-1] < r,由于 indices 的秩是 qindices 可以被视为一个 (q-1) 维张量,包含维度 < r 的 1-D 张量。我们将每个这样的张量视为 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 属于 ( 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) )

    约束输入和输出类型为任意张量类型。