工具与软件:
您好!
我一直在尝试将定制模型的推理转移到 AM62A 板的 C7x/MMA 内核、但没有很多成功。 与论坛上和 TIDL Tools / EdgeAI Academy 材料上讨论的绝大多数问题不同、我需要执行的推理类型不涉及图像处理。 相反,该模型对结构为熊猫数据帧的元数据进行分类。 该模型使用 sklearn 库进行训练、并使用 skl2onnx 和 TFLiteConverter 通过 keras 导出到 ONNX 和 TFLite。 两种转换后的模型都可以在 ARM 处理器上顺利运行、但在 C7x/MMA 加速器上不会运行。
尝试编译 TFLite 模型时、仅在 custom-artifies 文件夹中生成 tempDir。 对于 ONNX 模型、我尝试了两种编译方法:调整示例文件夹中提供的 Jupyter 笔记本、以及调整 examples/osrt_python/ort 文件夹中提供的 onnxrt_ep.py 脚本。 后者似乎会产生更好的结果、因为它会在 tempDir 中生成更多的文件并提供更广泛的调试信息。 ‘、脚本在"Quantization & Calibration for subgraph_0"期间挂起、从而导致在 custom-artifacts 文件夹中生成以下文件:
- allowedNode.txt
- onnxrtMetaData.txt
- /tempDir
- graphvizInfo.txt
- runtimes_visualization.svg
- subgraph_0_calib_raw_data.bin
- subgraph_0_tidl_io_1.bin
- subgraph_0_tidl_net.bin
- subgraph_0_tidl_net.bin.layer_info.txt
- subgraph_0_tidl_net.bin.svg
- subgraph_0_tidl_net.bin_netLog.txt
它在挂起前提供以下错误/警告时刻:
============= [Quantization & Calibration for subgraph_0 Started] =============
2025-01-08 14:46:34.193707173 [E:onnxruntime:, sequential_executor.cc:494 ExecuteKernel] Non-zero status code returned while running Gemm node. Name:'gemm_token_0' Status Message: /root/onnxruntime/onnxruntime/core/providers/cpu/math/gemm_helper.h:14 onnxruntime::GemmHelper::GemmHelper(const onnxruntime::TensorShape&, bool, const onnxruntime::TensorShape&, bool, const onnxruntime::TensorShape&) left.NumDimensions() == 2 || left.NumDimensions() == 1 was false.
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/root/examples/osrt_python/ort/onnxrt_ep.py", line 415, in run_model
classified_data = run_prediction(sess, scaled_data)
File "/home/root/examples/osrt_python/ort/onnxrt_ep.py", line 142, in run_prediction
predictions = session.run([output_name], {input_name: input_data})[0]
File "/usr/local/lib/python3.10/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 200, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Gemm node. Name:'gemm_token_0' Status Message: /root/onnxruntime/onnxruntime/core/providers/cpu/math/gemm_helper.h:14 onnxruntime::GemmHelper::GemmHelper(const onnxruntime::TensorShape&, bool, const onnxruntime::TensorShape&, bool, const onnxruntime::TensorShape&) left.NumDimensions() == 2 || left.NumDimensions() == 1 was false.
按照 TIDL git 中提供的建议、在模型的 deny_list 中包含可能有问题的节点、我修改了 model_configs.py 文件、如下所示:
"myModel": create_model_config(
source=AttrDict(
infer_shape=True,
),
preprocess=AttrDict(
),
session=AttrDict(
session_name="onnxrt",
model_path=os.path.join(models_base_path, "myModel.onnx"),
),
task_type="other",
extra_info=AttrDict(
),
optional_options={
'deny_list' : 'Gemm',
}
),
但是、虽然该节点已成功添加到不受支持的节点列表中、但脚本仍然挂起、并提供完全相同的输出。
------------------------------------------------------------------------------------------------------------------------------------------------------
| Node | Node Name | Reason |
------------------------------------------------------------------------------------------------------------------------------------------------------
| Gemm | gemm | Node gemm added to unsupported nodes as specified in deny list |
我用于执行上述编译的 Docker 文件在 SDK 版本10_00_08_00下配置、这与我在 AM62A 上的相同、ONNXRuntime 版本为1.14.0。 为了检查 Docker 和电路板的配置设置、我已成功执行 ARM 和 C7x/MMA 处理器的 examples/jupyter_notebooks 文件夹中的一些示例。
但是、考虑到 onnxrt_ep.py 脚本侧重于图像处理示例、我必须注释掉、修改并包含其他推理和数据预处理方法、才能编译我的自定义模型。 可以想象、评估我所做修改对整个编译过程的影响并不简单。 值得注意的是、编译过程成功识别了一组应卸载到加速器的节点、以及一组可能已卸载但出于编译过程中所述原因的节点。 我随附了我修改后的 onnxrt_ep.py 脚本版本、并在我已添加到文件的代码顶部添加了####:
e2e.ti.com/.../e2e_5F00_onnxrt_5F00_ep.zip
此致、
Giann。