---
title: aclrtAllocatorGetByStream
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/API/runtimeapi/aclcppdevg_03_1968.html
sourcePath: /source/zh/CANNCommunityEdition/920beta1/API/runtimeapi/aclcppdevg_03_1968.html
indexId: 1c7f000b29890d31a630786d2141453455a14ab9d224f2c25f305c85a75c4efc79
---
# aclrtAllocatorGetByStream

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Ascend 950PR / Ascend 950DT | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | ☓ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 功能说明

根据Stream查询用户注册的Allocator信息。


#### 函数原型

```
aclError aclrtAllocatorGetByStream(aclrtStream stream, aclrtAllocatorDesc *allocatorDesc, aclrtAllocator *allocator, aclrtAllocatorAllocFunc *allocFunc, aclrtAllocatorFreeFunc *freeFunc, aclrtAllocatorAllocAdviseFunc *allocAdviseFunc, aclrtAllocatorGetAddrFromBlockFunc *getAddrFromBlockFunc)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| stream | 输入 | 注册的类型，按照不同的子模块区分。类型定义请参见aclrtStream。 |
| allocatorDesc | 输出 | Allocator描述符指针。类型定义请参见aclrtAllocatorDesc。 |
| allocator | 输出 | 用户提供的Allocator对象指针。类型定义请参见aclrtAllocator。 |
| allocFunc | 输出 | 申请内存block的回调函数。 回调函数定义如下： typedef void \*(\*aclrtAllocatorAllocFunc)(aclrtAllocator allocator, size\_t size); |
| freeFunc | 输出 | 释放内存block的回调函数。 回调函数定义如下： typedef void (\*aclrtAllocatorFreeFunc)(aclrtAllocator allocator, aclrtAllocatorBlock block); |
| allocAdviseFunc | 输出 | 根据建议地址申请内存block的回调函数。 回调函数定义如下： typedef void \*(\*aclrtAllocatorAllocAdviseFunc)(aclrtAllocator allocator, size\_t size, aclrtAllocatorAddr addr); |
| getAddrFromBlockFunc | 输出 | 根据申请来的block获取device内存地址的回调函数。 回调函数定义如下： typedef void \*(\*aclrtAllocatorGetAddrFromBlockFunc)(aclrtAllocatorBlock block); |


#### 返回值说明

返回0表示成功，返回其他值表示失败，请参见aclError。
