Transpose

Transpose  // Operation that transposes axes of a tensor

Description

Warning

This op is not yet implemented in any backend.

Warning

This op is experimental and subject to change without notice.

Operation that transposes axes of an input tensor. This operation covers matrix transposition, and also more general cases on higher-rank tensors.

Inputs

Name

Element Type

Shape

arg

Any

Any

input_order

element::i64

[n], where n` is the rank of arg.

Outputs

Name

Element Type

Shape

output

Same as arg

P(ShapeOf(arg)), where P is the permutation supplied for input_order.

The input input_order must be a vector of shape [n], where n is the rank of arg, and must contain every integer in the range [0,n-1]. This vector represents a permutation of arg’s dimensions. For example,

arg Shape

input_order Value

output Shape

Comment

[3,4]

[1,0]

[4,3]

Transposes the arg matrix.

[3,3]

[1,0]

[3,3]

Transposes the arg matrix.

[3,3]

[1,0]

[3,3]

Transposes the arg matrix.

[3,4,8]

[2,0,1]

[8,3,4]

Moves the “last” dimension to the “first” position.

Mathematical Definition

\[\mathtt{output}_{i_0,i_1,...,i_n} = \mathtt{arg}_{i_{\mathtt{input_order}[0]},i_\mathtt{input_order}[1],...,i_\mathtt{input_order}[n]}.\]

Backprop

Not yet implemented.

C++ Interface

class Transpose : public ngraph::op::Op

Tensor transpose operation.

Public Functions

Transpose(const std::shared_ptr<Node> &arg, const std::shared_ptr<Node> &input_order)

Constructs a transpose operation.

Parameters
  • arg: Node producing the tensor to be transposed.

  • input_order: Node producing the permutation to apply to the axes of the input shape. Must be a vector of element type element::i64, with shape [n], where n is the rank of arg. The tensor’s value must contain every integer in the range [0,n-1].

void validate_and_infer_types()

Throws if the node is invalid.