已关闭
[Bug-Report|缺陷反馈]: topk.cpp 接口 TopkCommon 函数中,在只执行 AiCpu路径时也生成了AICore执行路径下的 indicesOut,导致无效显存的开销降低性能 #3082
LetsAiGo创建于  27 天前关闭于  26 天前
LetsAiGo
27 天前 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

一、问题描述 (必填)

topk.cpp 接口 TopkCommon 函数中,在只执行 AiCpu路径时也会生成AICore执行路径下的 indicesOut,导致无效显存的开销降低性能
https://gitcode.com/cann/ops-math/blob/master/math/topk/op_api/topk.cpp

aclTensor* indicesOut = nullptr;
if (IsRegBase() && !IsSortWithIndex(self, k, sorted)) {
    indicesOut = executor->AllocTensor(outShape, indicesDType, self->GetStorageFormat());
} else {
    indicesOut = executor->AllocTensor(outShape, op::DataType::DT_INT32, self->GetStorageFormat());
}

indicesOut 只在if (IsAiCoreSupport(self, k)) {} else{ } 的IsAiCoreSupport分支下使用。

当不满足IsAiCoreSupport时执行else 下的 AiCpu 分支,此时会导致无效的显存申请

优化点:indicesOut 的生成内置到 IsAiCoreSupport分支下,当执行 AiCpu 分支时不再申请显存

二、环境信息 (可选)

三、重现步骤 (可选)

四、预期结果 (可选)

💡 备注(选填)

likedislike
LLetsAiGo
27 天前 关联了pull request:修改Aicore下indicesOut的生成方式,在不需要indicesOut的AiCpu执行路径下不再生成,提升性能
LLetsAiGo
27 天前 修改了issue 的描述
陈思
陈思成员
26 天前 评论:

/assign @LetsAiGo

likedislike
CANN-robotCANN-robot成员
26 天前 将 LetsAiGo 设为负责人
CANN-robotCANN-robot成员
26 天前 关闭了 issue
CANN-robotCANN-robot成员
26 天前 添加了label:resolved