---
title: LoadGraph
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0181.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0181.html
indexId: 12405f135b3810af45089f5557ce581fbfbed2205980c0e0726fb7f0163e560572
---
# LoadGraph

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | x |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 头文件/库文件

- 头文件：#include <ge/ge_api_v2.h>
- 库文件：libge_runner_v2.so


#### 功能说明

加载图并为其执行做准备，包括申请与管理图运行所需的内存及计算流等资源。

说明：若在调用本接口前未执行CompileGraph完成图编译，则本接口将自动调用CompileGraph以完成编译。


#### 函数原型

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


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| graph\_id | 输入 | 要执行Graph对应的ID。 |
| options | 输入 | 执行阶段可能用到的options。map表，key为参数类型，value为参数值，描述Graph配置信息。 一般情况下可不填，与GEInitializeV2传入的全局options保持一致。 key和value类型为AscendString，如需单独配置当前Graph的配置信息时，可以通过此参数配置，支持的配置项请参见options参数说明>ge.exec.frozenInputIndexes和ge.exec.hostInputIndexes，当前只支持配置上述两个参数。 |
| stream | 输入 | 接口“aclrtCreateStream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg\_03\_0066.html)”创建的流，也可以设置为nullptr。当传入有效值时，若在加载过程中需要向流中下发任务，会下发到指定流上。 若与RunGraphWithStreamAsync接口配合使用，建议传入有效值。此时，通过LoadGraph加载的Stream与RunGraphWithStreamAsync运行时使用的Stream推荐为同一条流。若非同一条流，则需在LoadGraph后，对加载使用的Stream调用流同步接口“aclrtSynchronizeStream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg\_03\_0076.html)”完成同步。 若与RunGraph或RunGraphAsync接口配合使用，建议传入nullptr以简化流程。若传入有效值，则需在LoadGraph后、RunGraph/RunGraphAsync前调用“aclrtSynchronizeStream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg\_03\_0076.html)”完成流同步，以确保加载任务完成。 |


#### 返回值说明

| 参数名 | 类型 | 说明 |
| --- | --- | --- |
| \- | Status | GE\_CLI\_SESS\_RUN\_FAILED：执行子图时序列化转换失败。 SUCCESS：执行子图成功。 FAILED：执行子图失败。 |
