目录

使用CANN Kit加载ONNX模型转换后的OM模型报错

问题现象

执行OMG命令,将ONNX模型转换为OM模型后,在HarmonyOS 5.0上使用CANN Kit加载该OM模型后报错。

部分报错信息如下:

08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     reshape_check_support.cc ReshapeCheckFunc(41)::check reshape dimInfo fail
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Reshape_4] type [Reshape] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     permute_check_support.cc IsSupport(21)::realdimCnt > 4
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Transpose_2] type [Permute] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     vector_op_checker.cc IsSupport(87)::input dimCnt 5 > 4
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Sigmoid_2] type [Activation] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     split_desc.cc InitAttr(38)::too much dim count = 5
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     split_check_support.cc IsSupport(35)::init desc fail
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Split_2] type [SplitV] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetInputOriginalDims(69)::binary op get original input dimCnt error, dimCnt is 5.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetNCHWDims(218)::get input original dims error.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     vector_op_checker.cc IsSupport(164)::init desc fail
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     mul_check_support.cc IsSupport(39)::wrong params
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Mul_10] type [Mul] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetInputOriginalDims(69)::binary op get original input dimCnt error, dimCnt is 5.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetNCHWDims(218)::get input original dims error.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     vector_op_checker.cc IsSupport(164)::init desc fail
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     pow_check_support.cc IsSupport(27)::wrong params
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Pow_2] type [Pow] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetInputOriginalDims(69)::binary op get original input dimCnt error, dimCnt is 5.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetNCHWDims(218)::get input original dims error.
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     vector_op_checker.cc IsSupport(164)::init desc fail
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     mul_check_support.cc IsSupport(39)::wrong params
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   W     fe_sub_stores_manager.cc CheckSupported(302)::"CheckSupported: the op name [/model.24/Mul_11] type [Mul] is not supported in npucl store [elementary_lib]"
08-04 16:19:13.996   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     binary_desc.cc GetInputOriginalDims(69)::binary op get original input dimCnt error, dimCnt is 5.
08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     op_strategy.cc GetCompileInfo(39)::ConcatD SelectKernel failed!
08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     compile_task.cc GetStrategy(300)::GetCompileInfo failed!
08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     compile_task.cc Compile(175)::ConcatD /model.24/Concat_2 compileInfo is null.
08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     npu_graph_compiler.cc GenModelTaskDef(422)::"Call FusionTaskBuild failed."
08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     npu_graph_compiler.cc Compile(184)::"GenModelTaskDef failed"
08-04 16:19:13.940   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   E     model_compiler_util.cpp operator()(110)::"ModelCompiler::CompileGraph: subGraph SubGraph_2 compiled failed in cl NPUCL!"
08-04 16:19:13.940   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   E     general_model_compiler.cpp DoCompile(242)::"CompileGraph ge_default failed!"
08-04 16:19:13.943   58217-58217   C02150/com.hm.example/AI_INFRA  com.hm.example   E     general_model_compiler.cpp Compile(351)::"DoCompile(optimizerOptions, options, weightInfo, computeGraph, compiledModel) == SUCCESS" "false, return FAIL."
08-04 16:19:13.946   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   E     hcl_model_builder_impl.cpp BuildModel(568)::"BuildModelByHcl failed"
08-04 16:19:13.947   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   E     hcl_built_model_impl.cpp RestoreFromBuffer(259)::"restore model failed."
08-04 16:19:13.947   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   I     ai_timer_manager.cpp Initiate(114)::"create epollfd [82]"
08-04 16:19:13.947   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   I     ai_timer_manager.cpp Initiate(123)::"add pipe read end to epoll: success!"
08-04 16:19:13.947   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   I     ai_timer_manager.cpp CreateTimer(219)::"add timerfd [85] to epoll [82]"
08-04 16:19:13.947   58217-58217   C02150/com.hm.example/AI_INFRA  com.hm.example   E     hcl_built_model_itf.cpp CreateItfBuiltModel(50)::"clBuitModelImpl" "null, return FAIL."
08-04 16:19:13.947   58217-58217   C02154/com.hm.example/AI_FMK    com.hm.example   E     hiai_hdi_built_model.c HiaiHclBuiltModelRestore(83)::"HIAI_HCL_BuiltModel_Restore failed."
08-04 16:19:13.947   58217-58217   C02108/com.hm.example/HIAI      com.hm.example   E     [nodict] [invalidDomain]BuiltModelRestore failed
08-04 16:19:13.947   58217-58217   C02108/com.hm.example/HIAI      com.hm.example   E     [nodict] [invalidDomain]ret == OH_NN_SUCCESSfalse, return HIAI_COMPATIBILITY_INCOMPATIBLE.

背景知识

问题定位

  1. 第1段日志中的关键字“CheckSupported”表明当前是在检查模型中各算子在当前设备NPU上的支持情况,从日志以下关键信息可知:当前设备NPU不支持当前5维的算子。
    permute_check_support.cc IsSupport(21)::realdimCnt > 4
    vector_op_checker.cc IsSupport(87)::input dimCnt 5 > 4
    split_desc.cc InitAttr(38)::too much dim count = 5
  2. 第2段日志中的以下信息,表明NPU在进行分片时,ConcatD算子分片失败,最终不兼容报错。
    08-04 16:19:13.940   58217-58217   C02151/com.hm.example/AI_NPUCL  com.hm.example   E     op_strategy.cc GetCompileInfo(39)::ConcatD SelectKernel failed!
    ...
    08-04 16:19:13.947   58217-58217   C02108/com.hm.example/HIAI      com.hm.example   E     [nodict] [invalidDomain]ret == OH_NN_SUCCESSfalse, return HIAI_COMPATIBILITY_INCOMPATIBLE.

分析结论

当前模型中包含部分5维算子,在当前设备上不支持运行。

修改建议

将当前模型中的5维算子替换为4维及4维以下的模型算子。