AscendStream

Function Usage

Constructor of the AscendStream class.

Prototype

Prototype 1:

1
explicit AscendStream::AscendStream(int32_t deviceId = 0);

Prototype 2:

1
explicit AscendStream::AscendStream(int32_t deviceId, AscendStream::FlagType flag); // You can pass FlagType to construct fast and asynchronous streams. If the construction fails, the std::runtime_error exception is thrown.

Parameters

Parameter

Input/Output

Description

deviceId

Input

Specifies the device ID for the stream.

flag

Input

Indicates the flag type of the current stream. The data structure is as follows:
1
2
3
4
5
6
enum FlagType {
        DEFAULT = 0,
        FAST_LAUNCH = 1,
        FAST_SYNC = 2,
        LAUNCH_SYNC = 3,
};

Data structure description:

  • DEFAULT: Fast streams are not constructed.
  • FAST_LAUNCH: In this mode, internal system resources need to be pre-allocated when a stream is created. Therefore, the duration for creating a stream is prolonged, and that for delivering a task is shortened.
  • FAST_SYNC: In this mode, when the Synchronize API is called, the current thread is blocked and the task execution status is proactively queried. Once the task is complete, a response is returned immediately.
  • LAUNCH_SYNC: Both the FAST_LAUNCH and FAST_SYNC modes are set. This is the default configuration.
    NOTE:

    Only DEFAULT is supported by the Atlas 200I/500 A2 inference product.