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

#### 产品支持情况

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


#### 功能说明

用于指定图的不同内存类型的Fixed Feature内存基地址。

在调用本接口前，必须先调用CompileGraph接口进行图编译；内存大小从GetCompiledGraphSummary>GetAllFeatureMemoryTypeSize接口中获取。Feature内存指的是模型执行过程中所需要的中间内存（比如中间节点的输入输出等内存）。

- 当图中包含Fixed内存，但是用户未指定时，默认申请Fixed内存。
- 用户可以通过将地址设置为nullptr，size设置为0的方式，关闭默认申请Fixed内存的行为（内存类型为MEMORY_TYPE_P2P不支持该场景）。


#### 函数原型

```
Status SetGraphFixedFeatureMemoryBaseWithType(uint32_t graph_id, MemoryType type, const void *const memory, size_t size)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| graph\_id | 输入 | 子图对应的ID。 |
| type | 输入 | 内存类型，包含MemoryType::MEMORY\_TYPE\_DEFAULT、MemoryType::MEMORY\_TYPE\_P2P。 |
| memory | 输入 | 设置的Fixed Feature内存基地址。 |
| size | 输入 | 设置的Fixed Feature内存大小。一定要大于等于从GetCompiledGraphSummary>GetAllFeatureMemoryTypeSize接口中获取的。 |


#### 返回值说明

| 参数名 | 类型 | 说明 |
| --- | --- | --- |
| \- | Status | SUCCESS：设置成功。 FAILED：设置失败。 |


#### 约束说明

- 每个Graph每种内存类型只支持设置一次，不支持刷新。
- 设置内存类型为MEMORY_TYPE_DEFAULT的Fixed内存地址，不能与  UpdateGraphFeatureMemoryBase
接口同时使用。
- 当Fixed内存长度为0时，调用该接口不生效，且会生成warning日志提示用户。
-   options参数说明
中的ge.exec.staticMemoryPolicy参数设置为4或者  GE_USE_STATIC_MEMORY(https://www.hiascend.comdocument/detail/zh/canncommercial/900/maintenref/envvar/envref_07_0138.html)
环境变量设置为4时，此时动静态图支持内存复用；而该接口不支持地址刷新，因此动静态图内存复用场景下不支持通过将地址设置为nullptr、size设置为0的方式，关闭默认申请Fixed内存的行为。
