Transpose
Function Usage
Multi-dimensional transposition API of the tensor class. It performs transposition based on the given axes dimension arrangement. Asynchronous calling is supported.
It is supported by the Atlas inference product and
For the
The following conditions must be met:
- The input and output tensors must be on the device or DVPP side, and the parameters (stream and data memory) must be on the same device.
- For synchronization, the device where the data memory is located must be the same as the initialized device.
- The input and output parameters cannot exceed four dimensions, and must match the tensor types and shapes.
Prototype
1 | APP_ERROR Transpose(const Tensor &src, Tensor &dst, std::vector<int> axes, AscendStream &stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, supporting float16, float32, and uint8 data types. |
dst |
Output |
Tensor class, supporting float16, float32, and uint8 data types. An empty tensor can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance. The shape must be the shape of the src after the axis is exchanged according to the axes setting. For example, if the src shape is {1, 480, 640, 3} and axes value is {0, 2, 1, 3}, the shape of dst must be {1, 640, 480, 3}. |
axes |
Input |
std::vector<int> class. It specifies how the dimensions to be transposed are arranged.
|
stream |
Input |
AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |