Split

Function Usage

Image channel splitting API of the Tensor class. It is used to split a multi-channel image into single-channel images. Asynchronous calling is supported.

It is supported by the Atlas inference product and Atlas 200I/500 A2 inference product.

For the Atlas 200I/500 A2 inference product, preloading is supported (see Example of the Preloading File of the Initialization Operator).

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 shapes (except the last dimension) and types.

Prototype

1
APP_ERROR Split(const Tensor &src, std::vector<Tensor> &tv, AscendStream &stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

src

Input

Tensor class, supporting float16, float32, and uint8 data types.

HWC (three-dimensional) and NHWC (four-dimensional) are supported. The value of C (number of channels) is 3 or 4.

tv

Input/Output

std::vector<Tensor> class. It is used to store split single-channel tensors. Elements of the tensor class support the float16, float32, and uint8 data types. An empty vector can be passed. If the vector is not empty, call Tensor.Malloc() to allocate memory for tensors in the vector in advance.

The length of tv is the same as that of src, and the value of C is 1.

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.