Category: Data movement operations
Short description: GatherND gathers slices from input tensor into a tensor of a shape specified by indices.
Detailed description: GatherND gathers slices from data
by indices
and forms a tensor of a shape specified by indices
.
indices
is K
-dimensional integer tensor or K-1
-dimensional tensor of tuples with indices by which the operation gathers elements or slices from data
tensor. A position i_0, ..., i_{K-2}
in the indices
tensor corresponds to a tuple with indices indices[i_0, ..., i_{K-2}]
of a length equal to indices.shape[-1]
. By this tuple with indices the operation gathers a slice or an element from data
tensor and insert it into the output at position i_0, ..., i_{K-2}
as the following formula:
output[i_0, ..., i_{K-2},:,...,:] = data[indices[i_0, ..., i_{K-2}],:,...,:]
The last dimension of indices
tensor must be not greater than a rank of data
tensor, i.e. indices.shape[-1] <= data.rank
. The shape of the output can be computed as indices.shape[:-1] + data.shape[indices.shape[-1]:]
.
Example 1 shows how GatherND operates with elements from data
tensor:
Example 2 shows how GatherND operates with slices from data
tensor:
Example 3 shows how GatherND operates when indices
tensor has leading dimensions:
Attributes:
b
) is a leading number of dimensions of data
tensor and indices
representing the batches, and GatherND starts to gather from the b+1
dimension. It requires the first b
dimensions in data
and indices
tensors to be equal. In case non default value for batch_dims the output shape is calculated as (multiplication of indices.shape[:b]) + indices.shape[b:-1] + data.shape[(indices.shape[-1] + b):]
.[0; min(data.rank, indices.rank))
Example 4 shows how GatherND operates gathering elements for non-default batch_dims value:
Example 5 shows how GatherND operates gathering slices for non-default batch_dims value:
More complex example 6 shows how GatherND operates gathering slices with leading dimensions for non-default batch_dims value:
Inputs:
data
tensor of type T. This is a tensor of a rank not less than 1. Required.indices
tensor of type T_IND. This is a tensor of a rank not less than 1. It requires that all indices from this tensor will be in a range [0, s-1]
where s
is corresponding dimension to which this index is applied. Required.Outputs:
Types
Examples