LoadGraph

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

Loads a graph and prepares for its execution, including allocating and managing resources such as memory and computational streams required for graph execution.

Note: If the graph is not compiled by calling CompileGraph before this API is called, this API will automatically call CompileGraph to complete the compilation.

Prototype

1
Status LoadGraph(const uint32_t graph_id, const std::map<AscendString, AscendString> &options, void *stream) const

Parameters

Parameter

Input/Output

Description

graph_id

Input

ID of the graph to be executed.

options

Input

Options that may be used in the execution phase. A key-value mapping table, for the graph configuration. key indicates the parameter type, and value indicates the parameter value.

Generally, this parameter can be left blank, indicating using the same options configuration passed to GEInitializeV2.

The key and value parameters are of the AscendString type. You can use these parameters to configure the current graph separately. For details about the supported configuration options, see Command-Line Options > ge.exec.frozenInputIndexes and ge.exec.hostInputIndexes. Currently, only these two parameters can be configured.

stream

Input

Stream created by "aclrtCreateStream" of acl. It can also be set to nullptr. If a valid value is passed and tasks need to be delivered to a stream during loading, the tasks are delivered to a specified stream.

  • If this API is used together with RunGraphWithStreamAsync, it is recommended that a valid value be passed. In this case, it is recommended that the stream loaded by LoadGraph be the same as the stream used by RunGraphWithStreamAsync. If they are different, call the acl stream synchronization API "aclrtSynchronizeStream" to synchronize the stream used for loading after LoadGraph is called.
  • If this API is used together with RunGraph or RunGraphAsync, it is recommended that nullptr be passed to simplify the process. If a valid value is passed, call "aclrtSynchronizeStream" to synchronize the stream after LoadGraph is called and before RunGraph/RunGraphAsync is called to ensure that the loading task is complete.

Returns

Parameter

Type

Description

-

Status

GE_CLI_SESS_RUN_FAILED: Serialization failed when a subgraph is executed.

SUCCESS: Subgraph executed successfully.

FAILED: Failed to execute the subgraph.