Transpose#
Transpose - 13#
Version
name: Transpose (GitHub)
domain: main
since_version: 13
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 13.
Summary
Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).
Attributes
perm: A list of integers. By default, reverse the dimensions, otherwise permute the axes according to the values given.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
transposed (heterogeneous) - T: Transposed output.
Type Constraints
T in ( tensor(bfloat16), 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) ): Constrain input and output types to all tensor types.
Examples
default
shape = (2, 3, 4)
data = np.random.random_sample(shape).astype(np.float32)
node = onnx.helper.make_node(
'Transpose',
inputs=['data'],
outputs=['transposed']
)
transposed = np.transpose(data)
expect(node, inputs=[data], outputs=[transposed],
name='test_transpose_default')
all_permutations
shape = (2, 3, 4)
data = np.random.random_sample(shape).astype(np.float32)
permutations = list(itertools.permutations(np.arange(len(shape))))
for i in range(len(permutations)):
node = onnx.helper.make_node(
'Transpose',
inputs=['data'],
outputs=['transposed'],
perm=permutations[i]
)
transposed = np.transpose(data, permutations[i])
expect(node, inputs=[data], outputs=[transposed],
name='test_transpose_all_permutations_' + str(i))
Differences
0 | 0 | Transpose the input tensor similar to numpy.transpose. For example, when | Transpose the input tensor similar to numpy.transpose. For example, when |
1 | 1 | perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape | perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape |
2 | 2 | will be (2, 1, 3). | will be (2, 1, 3). |
3 | 3 |
|
|
4 | 4 | **Attributes** | **Attributes** |
5 | 5 |
|
|
6 | 6 | * **perm**: | * **perm**: |
7 | 7 | A list of integers. By default, reverse the dimensions, otherwise | A list of integers. By default, reverse the dimensions, otherwise |
8 | 8 | permute the axes according to the values given. | permute the axes according to the values given. |
9 | 9 |
|
|
10 | 10 | **Inputs** | **Inputs** |
11 | 11 |
|
|
12 | 12 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
13 | 13 | An input tensor. | An input tensor. |
14 | 14 |
|
|
15 | 15 | **Outputs** | **Outputs** |
16 | 16 |
|
|
17 | 17 | * **transposed** (heterogeneous) - **T**: | * **transposed** (heterogeneous) - **T**: |
18 | 18 | Transposed output. | Transposed output. |
19 | 19 |
|
|
20 | 20 | **Type Constraints** | **Type Constraints** |
21 | 21 |
|
|
22 | 22 | * **T** in ( | * **T** in ( |
23 | tensor(bfloat16), | ||
23 | 24 | tensor(bool), | tensor(bool), |
24 | 25 | tensor(complex128), | tensor(complex128), |
25 | 26 | tensor(complex64), | tensor(complex64), |
26 | 27 | tensor(double), | tensor(double), |
27 | 28 | tensor(float), | tensor(float), |
28 | 29 | tensor(float16), | tensor(float16), |
29 | 30 | tensor(int16), | tensor(int16), |
30 | 31 | tensor(int32), | tensor(int32), |
31 | 32 | tensor(int64), | tensor(int64), |
32 | 33 | tensor(int8), | tensor(int8), |
33 | 34 | tensor(string), | tensor(string), |
34 | 35 | tensor(uint16), | tensor(uint16), |
35 | 36 | tensor(uint32), | tensor(uint32), |
36 | 37 | tensor(uint64), | tensor(uint64), |
37 | 38 | tensor(uint8) | tensor(uint8) |
38 | 39 | ): | ): |
39 | 40 | Constrain input and output types to all tensor types. | Constrain input and output types to all tensor types. |
Transpose - 1#
Version
name: Transpose (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 1.
Summary
Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).
Attributes
perm: A list of integers. By default, reverse the dimensions, otherwise permute the axes according to the values given.
Inputs
data (heterogeneous) - T: An input tensor.
Outputs
transposed (heterogeneous) - T: Transposed output.
Type Constraints
T in ( 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) ): Constrain input and output types to all tensor types.