asc2.transpose
- asc2.transpose(input: LocalTensor, *axis: int) LocalTensor
Rearrange tensor dimensions in specific order. The supported data types are:
int8,int16,int32,int64,float16,bfloat16,float32,float64.- Parameters:
input – The input tensor
axis – Order of input dimensions in result. Swaps two last dimensions when no axis provided
- Returns:
The transposed tensor with swapped dimensions
- Return type:
- Raises:
TypeError – If input is not a LocalTensor
RuntimeError – If the input tensor dtype is not supported or axis is incorrect
Examples
Transpose a 2D tensor:
input = asc2.copy_in(x, [0, 0, 0], [32, 16]) result = input.transpose() # shape becomes [32, 16], same as input.transpose(1, 0)
Transpose a 3D tensor with specific order:
input = asc2.copy_in(x, [0, 0, 0], [32, 64, 16]) result = input.transpose(2, 0, 1) # shape becomes [16, 32, 64]
This function can also be called as a member function on
LocalTensor, asinput.transpose(...)instead oftranspose(input, ...).