RunGraphWithStreamAsync
Description
Runs the graph of a specified ID and returns the execution result. This API is asynchronous. This API is used to compile, load, and run graphs.
Both this function 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 the external allocator is set by calling RegisterExternalAllocator and the output memory is not 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 (before session destructor and GEFinalize).
Prototype
Status RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const std::vector<Tensor> &inputs,std::vector<Tensor> &outputs);
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
graph_id |
Input |
Subgraph ID. |
|
stream |
Input |
Stream on which a graph is executed. |
|
inputs |
Input |
Input data of the current subgraph, which is the memory on the device. |
|
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 executed by using the asynchronous API. FAILED: The graph fails to be executed by using the asynchronous API. |
Restrictions
- The memory allocated to the device must be determined before this API call.
- Before calling this API, you need to use aclrtCreateStream provided by AscendCL to create a stream. The stream can be created only when the default context is used.
- Before the graph execution result is output, the tasks on the stream are complete by using aclrtSynchronizeStream.
Parent topic: Graph Running APIs