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 分支时不再申请显存
💡 备注(选填)
/assign @LetsAiGo
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
indicesOut 只在if (IsAiCoreSupport(self, k)) {} else{ } 的IsAiCoreSupport分支下使用。
当不满足IsAiCoreSupport时执行else 下的 AiCpu 分支,此时会导致无效的显存申请
优化点:indicesOut 的生成内置到 IsAiCoreSupport分支下,当执行 AiCpu 分支时不再申请显存
二、环境信息 (可选)
三、重现步骤 (可选)
四、预期结果 (可选)
💡 备注(选填)