HarmonyOS 鸿蒙Next中模型转换时报错

HarmonyOS 鸿蒙Next中模型转换时报错 命令:call converter_lite --fmk=ONNX --modelFile=model.onnx --outputFile=qwen --saveType=MINDIR_LITE

check_result.json:

[ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:895] ConvertNodes] not support onnx data type IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:793] ConvertOnnxGraph] convert nodes failed. [ERROR] LITE(440060,1,?):2026-3-18 14:39:17 [r0\mindspore-lite\mindspore-lite\tools\converter\parser\onnx\onnx_model_parser.cc:706] Parse] convert onnx graph failed. [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\converter_funcgraph.cc:194] Load3rdModelToFuncgraph] Get funcGraph failed for fmk: 2 [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\converter_funcgraph.cc:278] Build] Load model file failed! [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\converter.cc:1205] HandleGraphCommon] Build func graph failed [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\converter.cc:1160] Convert] Handle graph failed: -1 Common error code. [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\converter.cc:1353] RunConverter] Convert model failed [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0/mindspore-lite/mindspore-lite/tools/converter/converter_context.h:60] PrintOps] =========================================== [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0/mindspore-lite/mindspore-lite/tools/converter/converter_context.h:61] PrintOps] UNSUPPORTED OP LIST: [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0/mindspore-lite/mindspore-lite/tools/converter/converter_context.h:63] PrintOps] FMKTYPE: ONNX, OP TYPE: IsNaN [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0/mindspore-lite/mindspore-lite/tools/converter/converter_context.h:65] PrintOps] =========================================== [ERROR] LITE(440060,1,?):2026-3-18 14:39:18 [r0\mindspore-lite\mindspore-lite\tools\converter\cxx_api\converter.cc:361] Convert] Convert model failed, ret=Common error code. ERROR [mindspore-lite\tools\converter\converter_lite\main.cc:107] main] Convert failed. Ret: Common error code. Convert failed. Ret: Common error code.


更多关于HarmonyOS 鸿蒙Next中模型转换时报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

尊敬的开发者,您好!根据您的问题,该功能正在评估中,感谢您的理解与支持。

更多关于HarmonyOS 鸿蒙Next中模型转换时报错的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


--inputShape="" 
--inputDataFormat=NCHW  模型的输入需要加上 尤其是 inputShape

鸿蒙Next模型转换报错通常涉及模型格式兼容性、算子支持或转换工具版本问题。检查模型是否为ONNX、TensorFlow等支持格式,确认算子是否在鸿蒙AI框架支持列表内。使用最新版模型转换工具,确保输入参数正确。错误日志中的具体代码可定位到算子不支持或格式解析失败等具体原因。

根据你提供的错误日志,问题核心在于模型转换工具 converter_lite 不支持 ONNX 模型中的 IsNaN 算子。

错误信息 not support onnx data type IsNaN 和最终的 UNSUPPORTED OP LIST: FMKTYPE: ONNX, OP TYPE: IsNaN 明确指出,当前版本的 MindSpore Lite 转换器无法解析或转换 ONNX 的 IsNaN 操作。

解决方案:

你需要修改原始的 ONNX 模型,移除或替换其中的 IsNaN 算子。具体操作取决于你的模型来源:

  1. 修改模型源文件(推荐):如果你是从 PyTorch、TensorFlow 等框架导出 ONNX 模型,请返回源框架的模型定义代码,找到并移除使用 torch.isnantf.math.is_nan 等产生 IsNaN 算子的代码逻辑。可以使用其他操作(如比较操作)来替代其功能,或者如果该算子对模型核心功能影响不大,考虑移除相关逻辑分支。

  2. 使用 ONNX 工具修改模型:你可以使用 onnxruntimeonnx 库的 Python API 来加载模型,遍历计算图节点,将 IsNaN 节点替换为一个等效的子图(例如,通过比较操作实现),或者直接删除这些节点(如果后续节点不依赖其输出)。之后保存修改后的 ONNX 文件,再尝试转换。

根本原因: HarmonyOS Next 的 AI 模型推理框架基于 MindSpore Lite。其模型转换器在持续更新以支持更多算子,但 IsNaN 算子目前不在其支持的 ONNX 算子列表中。你需要确保待转换的模型只包含转换器支持的算子。

完成模型修改后,重新执行你的转换命令 call converter_lite --fmk=ONNX --modelFile=model.onnx --outputFile=qwen --saveType=MINDIR_LITE 即可。

回到顶部