Context

Description

ATB Context class, which is used to manage global resources required for executing operations.

The Context class manages task flow queues, such as operation execution and TilingCopy, and manages the allocation and deallocation of tiling memory.

Definition

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Context {
public:
    Context() = default;
    virtual ~Context() = default;
    virtual Status SetExecuteStream(aclrtStream stream) = 0;
    virtual aclrtStream GetExecuteStream() const = 0;
    virtual Status SetAsyncTilingCopyStatus(bool enable) = 0;
    virtual bool GetAsyncTilingCopyStatus() const = 0;
    virtual Status SetExecuteStreams(const std::vector<aclrtStream> &streams) = 0;
    virtual std::vector<aclrtStream> GetExecuteStreams() = 0;
    virtual Status SetExecuteType(ExecuteType type) = 0;
    virtual ExecuteType GetExecuteType() = 0;
    virtual Status SetLaunchMode(LaunchMode mode) = 0;
    virtual LaunchMode GetLaunchMode() = 0;
};

Parameters

Member

Parameter

Return Value

Description

SetExecuteStream

stream

Status

stream indicates the execution stream on the device. Each stream is an execution queue. This function is used to set the passed-in stream to execute the corresponding operation.

  • stream: passed-in stream queue.

If the setting is successful, NO_ERROR is returned. In the case of a failure, see ErrorType.

GetExecuteStream

-

aclrtStream

Obtains the current execution stream.

SetAsyncTilingCopyStatus

enable

Status

Specifies whether to enable asynchronous copy of tiling information. If the function is enabled, streams and events are created for copying tiling information.

  • enable: passed-in flag, bool type.

If the setting is successful, NO_ERROR is returned. In the case of a failure, see ErrorType.

GetAsyncTilingCopyStatus

-

bool

Obtains the tiling copy status. If the status is obtained successfully, True is returned.

SetExecuteStreams

streams

Status

Sets the actual execution flow. When an operation is executed, the corresponding actual execution flow is matched from the context based on the configured streamId.

  • streams: a group of streams to be set.

Status value. If the setting is successful, NO_ERROR is returned. In the case of a failure, see ErrorType.

GetExecuteStreams

-

std::vector<aclrtStream>

Obtains the group of execution flows that are currently set in the context.

If the setting is successful, the group of execution flows that are currently set in the context is returned.

SetExecuteType

-

Status

Sets the Execute type.

GetExecuteType

-

ExecuteType

Obtains the Execute type of the current context.

SetLaunchMode

mode

Status

Sets the operator delivery mode.

  • mode: operator delivery mode.

Status value. If the setting is successful, NO_ERROR is returned. In the case of a failure, see ErrorType.

GetLaunchMode

-

LaunchMode

Returns the current operator delivery mode.