:nosearch: .. _op_ai_onnx_Gather-11: Gather - version 11 =================== This page documents version **11** of operator **Gather**. See :doc:`Gather` for the latest version (since version 13). - **Domain**: ``ai.onnx`` - **Since version**: 11 Given ``data`` tensor of rank r >= 1, and ``indices`` tensor of rank q, gather entries of the axis dimension of ``data`` (by default outer-most one as axis=0) indexed by ``indices``, and concatenates them in an output tensor of rank q + (r - 1). axis = 0 : Let k = indices[i{0}, ..., i{q-1}] Then output[i{0}, ..., i{q-1}, j{0}, ..., j{r-2}] = input[k , j{0}, ..., j{r-2}] .. code-block:: data = [ [1.0, 1.2], [2.3, 3.4], [4.5, 5.7], ] indices = [ [0, 1], [1, 2], ] output = [ [ [1.0, 1.2], [2.3, 3.4], ], [ [2.3, 3.4], [4.5, 5.7], ], ] axis = 1 : Let k = indices[i{0}, ..., i{q-1}] Then output[j{0}, i{0}, ..., i{q-1}, j{1}, ..., j{r-2}] = input[j{0}, k, j{1}, ..., j{r-2}] .. code-block:: data = [ [1.0, 1.2, 1.9], [2.3, 3.4, 3.9], [4.5, 5.7, 5.9], ] indices = [ [0, 2], ] axis = 1, output = [ [[1.0, 1.9]], [[2.3, 3.9]], [[4.5, 5.9]], ] **Inputs** - **data** (*T*): Tensor of rank r >= 1. - **indices** (*Tind*): Tensor of int32/int64 indices, of any rank q. 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. **Outputs** - **output** (*T*): Tensor of rank q + (r - 1). **Attributes** - **axis** (*int*): Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). **Type Constraints** - **T**: Constrain input and output types to any tensor type. Allowed types: 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). - **Tind**: Constrain indices to integer types Allowed types: tensor(int32), tensor(int64). Differences with previous version (1) ------------------------------------- **SchemaDiff**: ``Gather`` (domain ``'ai.onnx'``) * old version: 1 * new version: 11 * breaking: no **Documentation:** * line similarity: 0.83 (+15/-2 lines) .. code-block:: diff --- Gather v1 +++ Gather v11 @@ -2,7 +2,14 @@ Given `data` tensor of rank r >= 1, and `indices` tensor of rank q, gather entries of the axis dimension of `data` (by default outer-most one as axis=0) indexed by `indices`, and concatenates them in an output tensor of rank q + (r - 1). -Example 1: + +axis = 0 : + +Let +k = indices[i_{0}, ..., i_{q-1}] +Then +output[i_{0}, ..., i_{q-1}, j_{0}, ..., j_{r-2}] = input[k , j_{0}, ..., j_{r-2}] + ``` data = [ [1.0, 1.2], @@ -24,7 +31,13 @@ ], ] ``` -Example 2: +axis = 1 : + +Let +k = indices[i_{0}, ..., i_{q-1}] +Then +output[j_{0}, i_{0}, ..., i_{q-1}, j_{1}, ..., j_{r-2}] = input[j_{0}, k, j_{1}, ..., j_{r-2}] + ``` data = [ [1.0, 1.2, 1.9],