Welcome to our Support Center

GatherND

Description

Given data tensor of rank r >= 1, indices tensor of rank q >= 1, and batch_dims integer b, this operator gathers slices of data into an output tensor of rank q + r - indices_shape[-1] - 1 - b.

 

 

indices is an q-dimensional integer tensor, best thought of as a (q-1)-dimensional tensor of index-tuples into data, where each element defines a slice of data

batch_dims (denoted as b) is an integer indicating the number of batch dimensions, i.e the leading b number of dimensions of data tensor and indices are representing the batches, and the gather starts from the b+1 dimension.

Some salient points about the inputs’ rank and shape:

  1. r >= 1 and q >= 1 are to be honored. There is no dependency condition to be met between ranks r and q
  2. The first b dimensions of the shape of indices tensor and data tensor must be equal.
  3. b < min(q, r) is to be honored.
  4. The indices_shape[-1] should have a value between 1 (inclusive) and rank r-b (inclusive)
  5. All values in indices are expected to be within bounds [-s, s-1] along axis of size s (i.e.) -data_shape[i] <= indices[...,i] <= data_shape[i] - 1. It is an error if any of the index values are out of bounds.

The output is computed as follows:

The output tensor is obtained by mapping each index-tuple in the indices tensor to the corresponding slice of the input data.

  1. If indices_shape[-1] > r-b => error condition
  2. If indices_shape[-1] == r-b, since the rank of indices is qindices can be thought of as N (q-b-1)-dimensional tensors containing 1-D tensors of dimension r-b, where N is an integer equals to the product of 1 and all the elements in the batch dimensions of the indices_shape. Let us think of each such r-b ranked tensor as indices_slice. Each scalar value corresponding to data[0:b-1,indices_slice] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Example 1 below)
  3. If indices_shape[-1] < r-b, since the rank of indices is qindices can be thought of as N (q-b-1)-dimensional tensor containing 1-D tensors of dimension < r-b. Let us think of each such tensors as indices_slice. Each tensor slice corresponding to data[0:b-1, indices_slice , :] is filled into the corresponding location of the (q-b-1)-dimensional tensor to form the output tensor (Examples 2, 3, 4 and 5 below)

This operator is the inverse of ScatterND.

 

 

Input parameters

 

specified_outputs_namearray, this parameter lets you manually assign custom names to the output tensors of a node.

 Graphs in : cluster, ONNX model architecture.

 data (heterogeneous) – T : object, tensor of rank r >= 1.
 indices (heterogeneous) – tensor(int64) : object, tensor of rank q >= 1. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

 Parameters : cluster,

batch_dims : integer, the number of batch dimensions. The gather of indexing starts from dimension of data[batch_dims:].
Default value “0”.
 training? : boolean, whether the layer is in training mode (can store data for backward).
Default value “True”.
 lda coeff : float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value “1”.

 name (optional) : string, name of the node.

Output parameters

 

 output (heterogeneous) – T : object, tensor of rank q + r – indices_shape[-1] – 1.

Type Constraints

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)) : Constrain input and output types to any tensor type.

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents