BatchSplit
Function Usage
Image processing algorithm, batch splitting of tensors. The float16, float32, and uint8 types are supported. Asynchronous calling and memory reuse by inputs and outputs are supported.
It is supported by the Atlas inference product and
The following conditions must be met:
- The parameters (stream and data memory) of the API must be in 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 match the tensor types. The input tensor shape is three-dimensional or four-dimensional, for example, NWHC/NCHW/NHW.
- If the output is not empty, the size of the output vector must be equal to the batch size of the input tensors, and each tensor in the output vector is the result of removing the batch dimension from the input tensor. That is, NWHC/NCHW/NHW is split into several WHC/CHW/HW (specific quantity is determined by N).
Prototype
1 | APP_ERROR BatchSplit(const Tensor &src, std::vector<Tensor> &dst, bool isReplace, AscendStream &stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, input tensor. The tensor type can be the float16, float32, or uint8. Three-dimensional and four-dimensional tensors are supported. |
dst |
Output |
std::vector<Tensor> class, output. The float16, float32, and uint8 data types (consistent with that of src) are supported. Empty vectors can be passed. If a vector is not empty, call Tensor.Malloc() to allocate memory for tensors in the vector in advance. |
isReplace |
Input |
Boolean type. When the value is true, the output dst reuses the memory of the input src. Ensure that the life cycles of the two are the same. When the value is false, the output dst and input src do not affect each other (the memory release is determined by the lifetime of each). |
stream |
Input |
AscendStream type. The default value is AscendStream::DefaultStream(). If the parameter value is the default value or the value of isReplace is true, the API calling is synchronous. In other cases, the API calling is asynchronous. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |