RunGraphWithStreamAsync

Applicability

Product

Supported or Not

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference products

Atlas training products

Header File/Library File

  • Header file: #include <ge/ge_api_v2.h>
  • Library file: libge_runner_v2.so

Function Usage

Runs the graph of a specified ID and returns the execution result. This API is asynchronous.

  • This API is mutually exclusive with RunGraph and RunGraphAsync. If a graph has not been loaded by calling LoadGraph before this API is called, this API automatically calls LoadGraph to complete the loading.
  • Both this API and RunGraph are used to run the graph of a specified ID and output the result. Specifically:
    • This API is asynchronous.
    • inputs and outputs are memory on the device, and are allocated by the user before graph execution. You do not need to allocate the output memory in either of the following cases:
      • If an external allocator is set by calling RegisterExternalAllocator and no output memory is allocated, the GE calls the external allocator API to allocate memory. You need to free the memory before the external allocator is destructed.
      • If no external allocator is set and no output memory is allocated in the dynamic graph scenario, the GE uses the built-in allocator to allocate memory. The lifetime of the memory is the same as that of the graph. You need to free the memory before unloading the graph (that is, before GeSession destructor and GEFinalize).

Prototype

1
Status RunGraphWithStreamAsync(uint32_t graph_id, void *stream,const std::vector<gert::Tensor> &inputs,std::vector<gert::Tensor> &outputs)

Parameters

Parameter

Input/Output

Description

graph_id

Input

Subgraph ID.

stream

Input

Stream on which a graph is run.

inputs

Input

Input data of the current subgraph, which is the memory on the device.

If the value of ge.exec.hostInputIndexes parameter is specified using options, gert::Tensor of the corresponding index specifies the memory space on the host. For details about the gert::Tensor type, see Constructor.

outputs

Output

Output data of the current subgraph, which is the memory on the device.

Returns

Parameter

Type

Description

-

Status

SUCCESS: The graph is successfully run by using the asynchronous API.

FAILED: The graph fails to be run by using the asynchronous API.

Constraints

  • The memory required by gert::Tensor must be allocated before this API call.
  • Before calling this API, create a stream by using the "aclrtCreateStream" API provided by the acl. Before obtaining the output result, ensure that the tasks on the stream have been executed by using the "aclrtSynchronizeStream" API provided by the acl.

Examples

For details, see Running a Graph Asynchronously.