news 2026/5/9 16:43:33

CANN/opbase预留执行器接口

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
CANN/opbase预留执行器接口

预留接口

【免费下载链接】opbase本项目是CANN算子库的基础框架库,为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase

本章接口为预留接口,后续有可能变更或废弃,不建议开发者使用,开发者无需关注。

表 1接口列表

接口定义功能说明
aclOpExecutor()aclOpExecutor是用于记录整个host侧API运行信息的上下文结构,host侧API中几乎所有操作都以该数据结构为媒介,该函数为其构造函数。
CreateView(const aclTensor *tensor, const op::Shape &shape, int64_t offset)针对一个已有的aclTensor,创建一个它的view类tensor,两个tensor共享device内存,可以指定后者的shape和offset。
CreateView(const aclTensor *tensor, const op::Shape &oriShape, const op::Shape &storageShape, const op::Strides &oriStride, int64_t offset)针对一个已有的aclTensor,创建一个它的view类tensor,两个tensor共享device内存,可以指定后者的originShape、storageShape、originStride和offset。
UpdateTensorAddr(void *workspaceAddr, const size_t size)在workspace地址分配后,刷新每个workspace的地址。
GetWorkspaceAddr()获取workspace的起始指针。
GetWorkspaceSize()获取所需workspace的大小。
GetLinearWorkspaceSize()废弃接口,开发者无需关注。
GetWorkspaceOffsets()获取记录的workspace offset列表。
SetWorkspaceOffsets(const op::FVector<uint64_t> &workspaceOffsets)设置要记录的workspace offset列表。
Run()运行aclOpExecutor执行队列中的任务。
GetStream()获取当前执行流。
GetInputTensors()获取host侧API接口中的输入aclTensor。
GetOutputTensors()获取host侧API接口中的输出aclTensor。
GetLogInfo()获取aclOpExecutor中存储的日志相关信息。
SetLogInfo(const op::internal::OpLogInfo &logInfo)获取aclOpExecutor中存储的日志相关信息。
GetOpConfigInfo()获取算子运行时相关的配置信息。
SetOpConfigInfo(const op::OpConfigInfo &opConfigInfo)设置算子运行时相关的配置信息。
SetStream(aclrtStream stream)设置当前运行流。
AddTensorRelation(const aclTensor *tensorOut, const aclTensor *tensorMiddle)记录两个aclTensor间的地址等价关系,用于aclnn cache。
UpdateStorageAddr()在aclOpExecutor复用场景中,刷新aclTensor地址。
SetRepeatable()尝试设置当前aclOpExecutor为可复用状态。
IsRepeatable()判断当前aclOpExecutor是否为可复用状态。
FinalizeCache()完成aclnn cache最终的数据保存工作。
RepeatRunWithCache(void *workspaceAddr, const aclrtStream stream)复用aclOpExecutor场景,尝试利用aclnn cache完成任务执行。
CheckLauncherRepeatable()判断aclOpExecutor任务列表中的每个任务都允许aclOpExecutor复用。
AddCache()将aclOpExecutor中的aclnn cache保存到全局管理。
DeleteCache()删除aclnn cache。
GetOpExecCache()获取aclOpExecutor中记录的aclnn cache。
SetIOTensorList()记录host侧API的输入/输出aclTensor。
GetGraph()获取host侧API的执行图。
GetMagicNumber()获取magic number,用于不同对象的区分。
UniqueExecutor(const char *funcName)UniqueExecutor是aclOpExecutor的构造工厂,该函数为其构造函数。
UniqueExecutor()UniqueExecutor的构造函数。
get()获取UniqueExecutor中的aclOpExecutor指针。
ReleaseTo(aclOpExecutor **executor)将UniqueExecutor中的aclOpExecutor指针传递给目标aclOpExecutor指针。
UniqueExecutor(const UniqueExecutor &)废弃接口,开发者无需关注。
GetOpExecCacheFromExecutor(aclOpExecutor *)尝试将外部的aclOpExecutor转为aclnn cache对象。
InitL2Phase1Context(const char *l2Name, [[maybe_unused]] aclOpExecutor **executor)初始化host侧API一阶段中的部分DFX变量值。
InitL2Phase2Context([[maybe_unused]] const char* l2Name, aclOpExecutor* executor)初始化host侧API二阶段中的部分DFX变量值。
InitL0Context(const char *profilingName, aclOpExecutor* executor)初始化L0接口的部分DFX变量值。
CreatAiCoreKernelLauncher([[maybe_unused]] const char *l0Name, uint32_t opType, aclOpExecutor *executor, op::OpArgContext *args)创建一个AI Core任务对象。
CreatDSAKernelLauncher([[maybe_unused]] const char *l0Name, uint32_t opType, DSA_TASK_TYPE dsaTask, aclOpExecutor *executor, op::OpArgContext *args)创建一个DSA任务对象。
InferShape(uint32_t optype, op::OpArgList &inputs, op::OpArgList &outputs, op::OpArgList &attrs)执行指定算子的infer shape,获取infer shape的结果。
ConvertToTensor(const aclIntArray *value, op::DataType dataType)将aclIntArray类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const aclBoolArray *value, op::DataType dataType)将aclBoolArray类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const aclFloatArray *value, op::DataType dataType)将aclFloatArray类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const aclFp16Array *value, op::DataType dataType)将aclFp16Array类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const aclBf16Array *value, op::DataType dataType)将aclBf16Array类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const T *value, uint64_t size, op::DataType dataType)将T类型的host侧数据,转为一个host侧的aclTensor。
ConvertToTensor(const aclScalar *value, op::DataType dataType)将aclScalar类型的host侧数据,转为一个host侧的aclTensor。
AddToKernelLauncherList(op::KernelLauncher *obj)添加一个AI Core任务到执行队列。
AddToKernelLauncherListDvpp(uint32_t opType, op::KernelLauncher *obj, op::OpArgContext *args)添加一个DVPP任务到执行队列。
AddToKernelLauncherListCopyTask(uint32_t opType, op::KernelLauncher *obj, op::OpArgList &inputs, op::OpArgList &outputs, op::OpArgList &workspace)添加一个数据拷贝类任务到执行队列。
AddToKernelLauncherListAiCpu(int32_t opType, op::KernelLauncher *obj, op::OpArgContext *args)添加一个AI CPU任务到执行队列。
CommonOpExecutorRun(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)根据外部给出的aclOpExecutor及workspace、stream,执行上下文中的所有任务。

【免费下载链接】opbase本项目是CANN算子库的基础框架库,为算子提供公共依赖文件和基础调度能力。项目地址: https://gitcode.com/cann/opbase

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/9 16:43:04

基于MCP协议的智能核保系统:AI如何重塑保险风险评估流程

1. 项目概述&#xff1a;当保险遇上AI&#xff0c;核保智能化的新引擎最近在和一些保险科技圈的朋友交流时&#xff0c;大家频繁提到一个词&#xff1a;智能核保。传统保险核保&#xff0c;尤其是复杂的人身险、健康险或企业财产险&#xff0c;高度依赖核保师的经验。一份投保申…

作者头像 李华
网站建设 2026/5/9 16:34:13

Python slicing 三重世界:list、NumPy、pandas 的底层规则与工程避坑

1. 项目概述&#xff1a;为什么 slicing 是 Python 开发者每天都在用、却很少真正“懂透”的底层能力你有没有过这种经历&#xff1a;写完一段 slicing 代码&#xff0c;运行结果和预期差了一位——明明想取第2到第4个元素&#xff0c;结果只拿到两个&#xff1b;或者在 NumPy …

作者头像 李华
网站建设 2026/5/9 16:33:57

手机拍夜景总糊?聊聊UNet图像增强算法在移动端的落地挑战与优化思路

手机夜景拍摄模糊难题&#xff1a;UNet图像增强算法在移动端的工程实践 深夜的街头霓虹闪烁&#xff0c;举起手机想记录这一刻&#xff0c;却发现成片要么噪点密布要么模糊不清——这是移动端影像开发者最常收到的用户反馈之一。低光环境下的图像增强从来都是计算摄影领域的硬骨…

作者头像 李华
网站建设 2026/5/9 16:30:33

医疗AI临床落地指南:FUTURE-AI框架构建可信赖人工智能

1. 项目概述&#xff1a;为什么我们需要一份可信赖医疗AI的“国际共识指南”&#xff1f;如果你是一名医疗AI的研究者或开发者&#xff0c;过去几年里&#xff0c;你很可能经历过这样的场景&#xff1a;你精心打磨的模型在内部测试集上表现优异&#xff0c;准确率高达95%以上&a…

作者头像 李华