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

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| 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


#### 功能说明

将离线模型序列化并保存到指定文件中。


#### 函数原型

数据类型为string的接口后续版本会废弃，建议使用数据类型为非string的接口。


```
graphStatus aclgrphSaveModel(const std::string &output_file, const ModelBufferData &model)
graphStatus aclgrphSaveModel(const char_t *output_file, const ModelBufferData &model)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |  |  |
| --- | --- | --- | --- | --- |
| model | 输入 | 离线模型缓冲数据。详情请参见ModelBufferData。 1 2 3 4 5 struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint32\_t length; }; 其中data指向生成的模型数据，length代表该模型的实际大小。 | 1 2 3 4 5 | struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint32\_t length; }; |
| 1 2 3 4 5 | struct ModelBufferData { std::shared\_ptr<uint8\_t> data = nullptr; uint32\_t length; }; |  |  |  |
| output\_file | 输入 | 保存离线模型的文件名。生成的离线模型文件名会自动以.om后缀结尾，例如ir\_build\_sample.om或者 ir\_build\_sample\_linux\_x86\_64.om，若om文件名中包含操作系统及架构，则该om文件只能在该操作系统及架构的运行环境中使用。 |  |  |


#### 返回值说明

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


#### 约束说明

若生成的om模型文件名中含操作系统及架构，但操作系统及其架构与模型运行环境不一致时，需要与OPTION_HOST_ENV_OS、OPTION_HOST_ENV_CPU参数配合使用，设置模型运行环境的操作系统类型及架构。参数具体介绍请参见aclgrphBuildInitialize支持的配置参数。
