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

#### 产品支持情况

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


#### 头文件/库文件

- 头文件：#include <ge/ge_ir_build.h>
- 库文件：libge_compiler.so


#### 功能说明

将输入的一组Graph编译为适配AI处理器的离线模型。

与aclgrphBuildModel接口的区别是，该接口适用于权重更新场景。通过aclgrphBundleBuildModel接口生成离线模型缓存后，需要使用aclgrphBundleSaveModel接口落盘。


#### 函数原型

```
graphStatus aclgrphBundleBuildModel(const std::vector<ge::GraphWithOptions> &graph_with_options, ModelBufferData &model)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| graph\_with\_options | 输入 | 待编译的一组图和编译参数。该入参为一个结构体，包括如下参数： 1 2 3 4 struct GraphWithOptions { ge::Graph graph; std::map<AscendString, AscendString> build\_options; }; 一组图包括：权重初始化图，权重更新图，推理图，其中只有推理图支持设置如下options参数。 可以通过传入options参数配置离线模型编译配置信息，当前支持的配置参数请参见aclgrphBuildModel支持的配置参数。配置举例： 1 2 3 4 5 void PrepareOptions(std::map<AscendString, AscendString>& options) { options.insert({ {ge::ir\_option::EXEC\_DISABLE\_REUSED\_MEMORY, "1"} // close reuse memory }); } | 1 2 3 4 | struct GraphWithOptions { ge::Graph graph; std::map<AscendString, AscendString> build\_options; }; | 1 2 3 4 5 | void PrepareOptions(std::map<AscendString, AscendString>& options) { options.insert({ {ge::ir\_option::EXEC\_DISABLE\_REUSED\_MEMORY, "1"} // close reuse memory }); } |
| 1 2 3 4 | struct GraphWithOptions { ge::Graph graph; std::map<AscendString, AscendString> build\_options; }; |  |  |  |  |  |
| 1 2 3 4 5 | void PrepareOptions(std::map<AscendString, AscendString>& options) { options.insert({ {ge::ir\_option::EXEC\_DISABLE\_REUSED\_MEMORY, "1"} // close reuse memory }); } |  |  |  |  |  |
| model | 输出 | 编译生成的离线模型缓存。详情请参见ModelBufferData。 1 2 3 4 5 struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint64\_t length; }; 其中data指向生成的模型数据，length代表该模型的实际大小。 | 1 2 3 4 5 | struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint64\_t length; }; |  |  |
| 1 2 3 4 5 | struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint64\_t length; }; |  |  |  |  |  |


#### 返回值说明

| 参数名 | 类型 | 说明 |
| --- | --- | --- |
| \- | graphStatus | GRAPH\_SUCCESS(0)：成功。 其他值：失败，详情请参见"ge::graphStatus(https://www.hiascend.comdocument/detail/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi\_07\_00513.html)"。 |


#### 约束说明

该接口内多个图如果涉及共享同名variable算子，接口内部会进行variable算子加速融合，建议通过aclgrphConvertToWeightRefreshableGraphs接口生成，否则可能会出现variable算子格式不一致的问题。


#### 调用示例

完整调用示例请参见调用示例。
