AddGraph

Description

Adds a graph to a Session, in which a unique graph ID is generated.

Prototype

APIs using strings will be deprecated in later versions. Use APIs supporting non-string data instead.

Status AddGraph(uint32_t graph_id, const Graph &graph);
Status AddGraph(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options);
Status AddGraph(uint32_t graph_id, const Graph &graph, const std::map<AscendString, AscendString> &options);

Parameters

Parameter

Input/Output

Description

graph_id

Input

ID of the graph to run.

graph

Input

Graph to be loaded to the Session.

options

Input

A key-value mapping table, for the graph configuration. key indicates the options type, and value indicates the options value, both of type string.

Generally, this parameter can be left empty, indicating using the same options configuration passed to the GEInitialize call.

This parameter is available for configuring the current graph separately. For its keys and values, see Command-Line Options for more details.

Returns

Parameter

Type

Description

-

Status

GE_CLI_GE_NOT_INITIALIZED: GE is not initialized.

SUCCESS: The graph is successfully added.

FAILED: The graph fails to be added.

Restrictions

  • If graphs of the same Session are registered by using this API, all graphIds point to one graph object, causing disorder.
  • Do not use the same graphId to add different graph objects. In this case, only the graph object added at the first time is retained.
  • When this API is used, Session directly modifies the added graph object. To protect the original graph object from any impact after AddGraph is used, call AddGraphWithCopy, which copies a graph object in Session and modifies only the copy of the graph object.