ExecuteGraphWithStreamAsync
Header File/Library File
- Header file: #include <ge/ge_api.h>
- Library file: libge_runner.so
Function Usage
Asynchronously runs the graph of a specified ID and returns the execution result.
Both this function and RunGraphWithStreamAsync are used to run the graph of a specified ID and output the result. Unlike RunGraphWithStreamAsync:
- The CompileGraph and LoadGraph processes (asynchronous graph run) must be completed before this API call.
- The data type of inputs and outputs is gert::Tensor. For details, see Constructor inputs and outputs are memory on the device and are allocated by the user before graph execution.
If the output memory is not allocated in either of the following cases, pass an empty outputs container.
- 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 you do not set an external allocator, GE uses the built-in allocator to allocate memory. The memory lifetime is tied to the graph lifetime. You need to proactively free the memory before graph unloading (before session destruction or GEFinalize calling), for example, by calling outputs.clear(). Failure to do so may result in undefined behavior.
Prototype
1
|
Status ExecuteGraphWithStreamAsync(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 |
ID of the graph to be run. |
|
stream |
Input |
Stream on which the graph is executed. |
|
inputs |
Input |
Input tensors of the computational graph, which are memory allocated on the device. If the value of the ge.exec.hostInputIndexes parameter is specified using options, Tensor of the corresponding index specifies the memory space on the host. |
|
outputs |
Output |
Output tensors of the computational graph, which are memory allocated 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 required by Tensor must be allocated before this API call.
- The CompileGraph and LoadGraph processes must be completed before this API is called.
- A stream must be created using aclrtCreateStream provided by acl before this API call.
- Before the graph execution result is obtained, the tasks on the stream must be completed by using the aclrtSynchronizeStream API provided by acl.