Transpose - version 23#

This page documents version 23 of operator Transpose. See Transpose for the latest version (since version 25).

  • Domain: ai.onnx

  • Since version: 23

Returns a transpose of the input tensor. (Similar to numpy.transpose). The optional attribute perm must be a permutation of the dimensions of the input tensor. Axis i of the output tensor corresponds to the axis perm[i] of the input tensor. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3). When perm=(1, 2, 0), given an input tensor of shape (1, 2, 3), the output shape will be (2, 3, 1). If the attribute perm is omitted, its default value is (n-1, ..., 0), where n is the rank of the input tensor.

Inputs

  • data (T): An input tensor.

Outputs

  • transposed (T): Transposed output.

Attributes

  • perm (int[]): A list of integers. By default, reverse the dimensions, otherwise permute the axes according to the values given. Its length must be equal to the rank of the input.

Type Constraints

  • T: Constrain input and output types to all tensor types. Allowed types: tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(float4e2m1), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).

Examples#

test_cc_shape_inference_tiny_llm_inlined

Node:
  Transpose(query_4d) -> (query_heads)
  Attributes:
    perm = [0, 2, 1, 3]

Differences with previous version (21)#

SchemaDiff: Transpose (domain 'ai.onnx')

  • old version: 21

  • new version: 23

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(float4e2m1)’]