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

#### 产品支持情况

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


#### 头文件/库文件

- 头文件：#include <ge/ge_api.h>
- 库文件：libge_runner.so


#### 功能说明

用户将自己的Allocator注册给GE，适用于使用用户的内存池场景。

此接口需要配合LoadGraph、RunGraphWithStreamAsync或ExecuteGraphWithStreamAsync接口使用，并且需要在LoadGraph接口调用前注册。


#### 函数原型

```
Status RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| stream | 输入 | 指定Allocator注册在哪个Stream上。 |
| allocator | 输入 | 用户Allocator对象的智能指针。Allocator基于"Allocator(https://www.hiascend.comdocument/detail/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi\_07\_00277.html)"派生。 |


#### 返回值说明

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


#### 约束说明

- 对于同一条流，多次调用本接口，以最后一次注册为准。
- 对于不同流，如果用户使用同一个Allocator，不可以多条流并发执行，在执行下一条Stream前，需要对上一Stream做流同步。
- 将Allocator中的内存释放给操作系统前，需要先调用“aclrtSynchronizeStream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0076.html)”接口执行流同步，确保Stream中的任务已执行完成。
