RegisterExternalAllocator
函数功能
用户将自己的Allocator注册给GE,适用于使用用户的内存池场景。
函数原型
Status RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const;
参数说明
返回值
参数名 |
类型 |
描述 |
---|---|---|
- |
Status |
SUCCESS:设置成功。 FAILED:设置失败。 |
约束说明
- 此接口需要配合RunGraphWithStreamAsync或ExecuteGraphWithStreamAsync接口使用,并且需要在上述两个接口调用前注册。
- 对于同一条流,多次调用本接口,以最后一次注册为准。
- 对于不同流,如果用户使用同一个Allocator,不可以多条流并发执行,在执行下一条Stream前,需要对上一Stream做流同步。
- 将Allocator中的内存释放给操作系统前,需要先调用aclrtSynchronizeStream接口执行流同步,确保Stream中的任务已执行完成。
父主题: Graph运行接口