使用MindSpore Lite进行模型部署时,转换出的*.ms模型推理失败。
模型推理失败的问题需要借助日志报错信息来分析,出现该问题的可能原因及对应日志信息如下:
模型文件错误,日志报错信息:
- [mindspore/lite/src/lite_model.cc:**] ConstructModel] The model buffer is invalid and fail to create graph.
- [mindspore/lite/src/lite_model.cc:**] ImportFromBuffer] construct model failed.
模型文件和推理包版本不兼容,日志报错信息:
- [mindspore/lite/src/lite_model.cc:**] ConstructModel] Maybe this is a model transferred out using the conversion tool before 1.1.0.
- [mindspore/lite/src/lite_model.cc:**] ImportFromBuffer] construct model failed.
模型输入为动态shape,需指定,日志报错信息:
- [mindspore/lite/src/common/tensor_util.cc:**] CheckTensorsInvalid] The shape of tensor contains negative dimension, check the model and assign the input shape with method Resize().
- [mindspore/lite/src/lite_session.cc:**] RunGraph] CheckInputs failed.
检查报错日志,查找是否包含上述场景中所展示的错误信息。
步骤1:检查模型文件是否有效。
步骤2:检查模型文件和推理框架的版本是否匹配。
步骤3:检查模型输入shape是否有效。