Transpose
Function Usage
You can specify a group of axis dimensions (axes) to transpose the input tensor data. If no axis dimension is specified, the tensor data is transposed in reverse order by default.
This function supports memory reuse for the output data. You can transfer the output data by using the pre-allocated memory (the memory size must be the same as the input memory size).
This function can be performed only on the host. To process tensor data on the device, call ToHost to transfer the data from the device to the host, and then perform transposition.
Prototype
1 | friend APP_ERROR Tensor::Transpose(const Tensor &input, Tensor &output, std::vector<uint32_t> axes = {}); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
input |
Input |
Tensor class to be transposed. Two, three, or four dimensions are supported. The data type can be float32, float16, or uint8. |
output |
Output |
Tensor class after transposition. |
axes |
Input |
Transposition option. The default value is null. If axes are not specified, reverse axes are generated by default to transpose the data in input in reverse order. For example, the reverse axes generated for a three-dimensional tensor are {2, 1, 0} by default. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |