DML_REVERSE_SUBSEQUENCES_OPERATOR_DESC structure (directml.h)

Reverses the elements of one or more subsequences of a tensor. The set of subsequences to be reversed is chosen based on the provided axis and sequence lengths.

Syntax

struct DML_REVERSE_SUBSEQUENCES_OPERATOR_DESC {
  const DML_TENSOR_DESC *InputTensor;
  const DML_TENSOR_DESC *SequenceLengthsTensor;
  const DML_TENSOR_DESC *OutputTensor;
  UINT                  Axis;
};

Members

InputTensor

Type: const DML_TENSOR_DESC*

The input tensor containing elements to be reversed.

SequenceLengthsTensor

Type: const DML_TENSOR_DESC*

A tensor containing a value for each subsequence to be reversed, denoting the length in elements of that subsequence. Only the elements within the length of the subsequence are reversed; the remaining elements along that axis are copied to the output unchanged.

This tensor must have dimension count and sizes equal to the InputTensor, except for the dimension specified by the Axis parameter. The size of the Axis dimension must be 1. For example if the InputTensor has sizes of {2,3,4,5}, and Axis is 1, then the sizes of the SequenceLengthsTensor must be {2,1,4,5}.

If the length of a subsequence exceeds the maximum number of elements along that axis, then this operator behaves as if the value were clamped to the maximum.

OutputTensor

Type: const DML_TENSOR_DESC*

The output tensor to write the results to. This tensor must have the same sizes and data type as the InputTensor.

Axis

Type: UINT

The index of the dimension to reverse elements over. This value must be less than the DimensionCount of the InputTensor.

Examples

Example 1

InputTensor: (Sizes:{1,1,3,4}, DataType:FLOAT32)
[[[[1,  2,  3,  4],
   [5,  6,  7,  8],
   [9, 10, 11, 12]]]]
   
SequenceTensor: (Sizes:{1,1,3,1}, DataType:UINT32)
[[[[2],
   [4],
   [3]]]]

Axis: 3

OutputTensor: (Sizes:{1,1,3,4}, DataType:FLOAT32)
[[[[ 2,  1,  3,  4],
   [ 8,  7,  6,  5],
   [11, 10,  9, 12]]]]

Example 2. Reversing along a different axis

InputTensor: (Sizes:{1,1,3,4}, DataType:FLOAT32)
[[[[1,  2,  3,  4],
   [5,  6,  7,  8],
   [9, 10, 11, 12]]]]
   
SequenceTensor: (Sizes:{1,1,1,4}, DataType:UINT32)
[[[[2, 3, 1, 0]]]]

Axis: 2

OutputTensor: (Sizes:{1,1,3,4}, DataType:FLOAT32)
[[[[5, 10,  3,  4], // Notice that sequence lengths of 1 and 0 are effective nops
   [1,  6,  7,  8],
   [9,  2, 11, 12]]]]

Availability

This operator was introduced in DML_FEATURE_LEVEL_2_1.

Tensor constraints

  • InputTensor, OutputTensor, and SequenceLengthsTensor must have the same DimensionCount.
  • InputTensor and OutputTensor must have the same DataType.

Tensor support

DML_FEATURE_LEVEL_5_0 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
SequenceLengthsTensor Input 1 to 8 UINT64, UINT32
OutputTensor Output 1 to 8 FLOAT64, FLOAT32, FLOAT16, INT64, INT32, INT16, INT8, UINT64, UINT32, UINT16, UINT8

DML_FEATURE_LEVEL_4_0 and above

Tensor Kind Supported dimension counts Supported data types
InputTensor Input 1 to 8 FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8
SequenceLengthsTensor Input 1 to 8 UINT32
OutputTensor Output 1 to 8 FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8

DML_FEATURE_LEVEL_3_0 and above

Tensor Kind Supported dimension counts Supported data types
InputTensor Input 4 to 5 FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8
SequenceLengthsTensor Input 4 to 5 UINT32
OutputTensor Output 4 to 5 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
SequenceLengthsTensor Input 4 UINT32
OutputTensor Output 4 FLOAT32, FLOAT16, INT32, INT16, INT8, UINT32, UINT16, UINT8

Requirements

Requirement Value
Header directml.h