# DML_GATHER_ELEMENTS_OPERATOR_DESC structure (directml.h)

Gathers elements from the input tensor along the given axis using the indices tensor to remap into the input. This operator performs the following pseudocode, with the exact behavior dependent on the axis, input dimension count, and indices dimension count.

```
output[i, j, k, ...] = input[index[i, j, k, ...], j, k, ...] // if axis == 0
output[i, j, k, ...] = input[i, index[i, j, k, ...], k, ...] // if axis == 1
output[i, j, k, ...] = input[i, j, index[i, j, k, ...], ...] // if axis == 2
...
```

## Syntax

```
struct DML_GATHER_ELEMENTS_OPERATOR_DESC {
const DML_TENSOR_DESC *InputTensor;
const DML_TENSOR_DESC *IndicesTensor;
const DML_TENSOR_DESC *OutputTensor;
UINT Axis;
};
```

## Members

`InputTensor`

Type: **const DML_TENSOR_DESC***

The tensor to read from.

`IndicesTensor`

Type: **const DML_TENSOR_DESC***

The indices into the input tensor along the active axis. The *Sizes* must match *InputTensor.Sizes* for every dimension except *Axis*.

Starting with `DML_FEATURE_LEVEL_3_0`

, this operator supports negative index values when using a signed integral type with this tensor. Negative indices are interpreted as being relative to the end of the axis dimension. For example, an index of -1 refers to the last element along that dimension.

`OutputTensor`

Type: **const DML_TENSOR_DESC***

The tensor to write the results to. The *Sizes* must match *IndicesTensor.Sizes*, and *DataType* must match *InputTensor.DataType*.

`Axis`

Type: **UINT**

The axis dimension of *InputTensor* to gather along, ranging `[0, *InputTensor.DimensionCount*)`

.

## Examples

```
Axis = 0
InputTensor: (Sizes:{3,3}, DataType:FLOAT32)
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
IndicesTensor: (Sizes:{2,3}, DataType:UINT32)
[[1, 2, 0],
[2, 0, 0]]
// output[y, x] = input[indices[y, x], x]
OutputTensor: (Sizes:{2,3}, DataType:UINT32)
[[4, 8, 3], // select elements vertically from data
[7, 2, 3]]
```

## Availability

This operator was introduced in `DML_FEATURE_LEVEL_2_1`

.

## Tensor constraints

`IndicesTensor`

,*InputTensor*, and*OutputTensor*must have the same*DimensionCount*.*InputTensor*and*OutputTensor*must have the same*DataType*.

## Tensor support

### DML_FEATURE_LEVEL_4_1 and above

Tensor | Kind | Supported dimension counts | Supported data types |
---|---|---|---|

InputTensor | Input | 1 to 8 | FLOAT64, FLOAT32, FLOAT16, INT64, INT32, INT16, INT8, UINT64, UINT32, UINT16, UINT8 |

IndicesTensor | Input | 1 to 8 | INT64, INT32, UINT64, UINT32 |

OutputTensor | Output | 1 to 8 | FLOAT64, FLOAT32, FLOAT16, INT64, INT32, INT16, INT8, UINT64, UINT32, UINT16, UINT8 |

### DML_FEATURE_LEVEL_3_0 and above

Tensor | Kind | Supported dimension counts | Supported data types |
---|---|---|---|

InputTensor | Input | 1 to 8 | FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8 |

IndicesTensor | Input | 1 to 8 | INT64, INT32, UINT64, UINT32 |

OutputTensor | Output | 1 to 8 | FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8 |

### DML_FEATURE_LEVEL_2_1 and above

Tensor | Kind | Supported dimension counts | Supported data types |
---|---|---|---|

InputTensor | Input | 4 | FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8 |

IndicesTensor | Input | 4 | UINT32 |

OutputTensor | Output | 4 | FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8 |

## Requirements

Minimum supported client |
Windows 10 Build 20348 |

Minimum supported server |
Windows 10 Build 20348 |

Header |
directml.h |