Merged
[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release #1126
FengHaozhanAdd on 22 days ago
[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release #1126
Merged
FengHaozhanAdd on 22 days ago
Total: 2 files changed+19-10
@@ -532,6 +532,7 @@ std::shared_ptr<CpuKernelContext> CpuKernelCache::GetCpuKernelContext(
532 }532 }
533 KERNEL_LOG_DEBUG(533 KERNEL_LOG_DEBUG(
534 "get cache success, workspace addr=%ld.", ext_info_msg->workspace_addr, ext_info_msg->workspace_size);534 "get cache success, workspace addr=%ld.", ext_info_msg->workspace_addr, ext_info_msg->workspace_size);
535+ nodedef_proto = cache->proto;
535 return cache->context;536 return cache->context;
536 }537 }
537 }538 }
@@ -611,18 +612,23 @@ int32_t CpuKernelCache::ParseRunKernelParam(
611/*612/*
612 * dispatch cpu kernel: V2 优先, V1 兜底.613 * dispatch cpu kernel: V2 优先, V1 兜底.
613 */614 */
614-uint32_t CpuKernelCache::DispatchCpuKernel(CpuKernelContext& ctx, ExtInfoMsg& ext_info_msg) const615+uint32_t CpuKernelCache::DispatchCpuKernel(const std::shared_ptr<CpuKernelContext>& ctx,
616+ const std::shared_ptr<ExtInfoMsg>& ext_info_msg,
617+ const std::shared_ptr<NodeDef>& nodedef_proto) const
615{618{
616- const std::string& op_type = ctx.GetOpType();619+ const std::string& op_type = ctx->GetOpType();
617 const bool hit_v2 = CpuKernelRegister::Instance().IsRegisteredV2(op_type);620 const bool hit_v2 = CpuKernelRegister::Instance().IsRegisteredV2(op_type);
618- if (ext_info_msg.async_flag) {621+ if (ext_info_msg->async_flag) {
619- auto cb = [this, &ctx, &ext_info_msg]() { return UpdateFWKOutputShape(ext_info_msg, ctx); };622+ auto cb = [this, ctx, ext_info_msg, nodedef_proto]() {
623+ (void)nodedef_proto;
624+ return UpdateFWKOutputShape(*ext_info_msg, *ctx);
625+ };
620 return hit_v2 ? CpuKernelRegister::Instance().RunCpuKernelAsyncV2(626 return hit_v2 ? CpuKernelRegister::Instance().RunCpuKernelAsyncV2(
621- ctx, ext_info_msg.wait_type, ext_info_msg.wait_id, cb) :627+ *ctx, ext_info_msg->wait_type, ext_info_msg->wait_id, cb) :
622 CpuKernelRegister::Instance().RunCpuKernelAsync(628 CpuKernelRegister::Instance().RunCpuKernelAsync(
623- ctx, ext_info_msg.wait_type, ext_info_msg.wait_id, cb);629+ *ctx, ext_info_msg->wait_type, ext_info_msg->wait_id, cb);
624 }630 }
625- return hit_v2 ? CpuKernelRegister::Instance().RunCpuKernelV2(ctx) : CpuKernelRegister::Instance().RunCpuKernel(ctx);631+ return hit_v2 ? CpuKernelRegister::Instance().RunCpuKernelV2(*ctx) : CpuKernelRegister::Instance().RunCpuKernel(*ctx);
626}632}
627 633 
628int32_t CpuKernelCache::RunKernel(void* param)634int32_t CpuKernelCache::RunKernel(void* param)
@@ -646,7 +652,7 @@ int32_t CpuKernelCache::RunKernel(void* param)
646 return -1;652 return -1;
647 }653 }
648 654 
649- ret = DispatchCpuKernel(*ctx, *ext_info_msg);655+ ret = DispatchCpuKernel(ctx, ext_info_msg, node_def_proto);
650 if (!ext_info_msg->async_flag) {656 if (!ext_info_msg->async_flag) {
651 if (ret != KERNEL_STATUS_OK) {657 if (ret != KERNEL_STATUS_OK) {
652 if ((ret == KERNEL_STATUS_SILENT_FAULT) || (ret == KERNEL_STATUS_DETECT_FAULT) ||658 if ((ret == KERNEL_STATUS_SILENT_FAULT) || (ret == KERNEL_STATUS_DETECT_FAULT) ||
@@ -691,7 +697,7 @@ int32_t CpuKernelCache::RunCpuKernelWithBlock(void* param, struct BlkDimInfo* bl
691 return -1;697 return -1;
692 }698 }
693 699 
694- ret = DispatchCpuKernel(*ctx, *ext_info_msg);700+ ret = DispatchCpuKernel(ctx, ext_info_msg, node_def_proto);
695 if (!ext_info_msg->async_flag) {701 if (!ext_info_msg->async_flag) {
696 if (ret != KERNEL_STATUS_OK) {702 if (ret != KERNEL_STATUS_OK) {
697 return -1;703 return -1;
@@ -717,6 +723,7 @@ std::shared_ptr<CpuKernelContext> CpuKernelCache::GetCpuKernelContextWithBlock(
717 auto cache = GetCache(kernel_id);723 auto cache = GetCache(kernel_id);
718 if (cache != nullptr) {724 if (cache != nullptr) {
719 KERNEL_LOG_INFO("Get kernel from cache success.");725 KERNEL_LOG_INFO("Get kernel from cache success.");
726+ nodedef_proto = cache->proto;
720 return cache->context;727 return cache->context;
721 }728 }
722 }729 }
@@ -224,7 +224,9 @@ private:
224 * dispatch cpu kernel based on V2/V1 registry.224 * dispatch cpu kernel based on V2/V1 registry.
225 * @return uint32_t: raw kernel status code225 * @return uint32_t: raw kernel status code
226 */226 */
227- uint32_t DispatchCpuKernel(CpuKernelContext& ctx, ExtInfoMsg& ext_info_msg) const;227+ uint32_t DispatchCpuKernel(const std::shared_ptr<CpuKernelContext>& ctx,
228+ const std::shared_ptr<ExtInfoMsg>& ext_info_msg,
229+ const std::shared_ptr<NodeDef>& nodedef_proto) const;
228};230};
229} // namespace aicpu231} // namespace aicpu
230#endif // AICPU_CPU_KERNEL_CACHE_H_232#endif // AICPU_CPU_KERNEL_CACHE_H_