AttributeError: 'NoneType' object has no attribute 'decode' during TFLite to ONNX conversion
Describe the bug
I encountered an error while attempting to convert a TFLite model to ONNX using the tf2onnx tool. using the following command:
python -m tf2onnx.convert --tflite keyword_scrambled.tflite
The error seems to originate from the tf2onnx/tflite_utils.py file, where it attempts to call tensor.Name().decode(). However, tensor appears to be None, resulting in an AttributeError.
Urgency
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 18.04*):
- TensorFlow Version: tf-nightly 2.18.0.dev20240706
- Python version: 3.10.14
- ONNX version (if applicable, e.g. 1.11*): 1.13.0
- ONNXRuntime version (if applicable, e.g. 1.11*): 1.13.0
- tf2onnx: 1.16.1
To Reproduce
- Install TensorFlow nightly version (2.18.0.dev20240706), ONNX 1.13.0, and tf2onnx 1.16.1.
- Use tf2onnx.convert to attempt to convert a TensorFlow Lite model to ONNX.
- The conversion fails with an AttributeError.
Screenshots
Additional context
tflite model from https://github.com/tensorflow/tflite-micro/blob/main/tensorflow/lite/micro/models/keyword_scrambled.tflite
2024-10-21 11:40:04,176 - INFO - Using tensorflow=2.18.0.dev20240706, onnx=1.13.0, tf2onnx=1.16.1/15c810
2024-10-21 11:40:04,176 - INFO - Using opset <onnx, 15>
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf-nightly/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf-nightly/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/opt/homebrew/Caskroom/miniforge/base/envs/tf-nightly/lib/python3.10/site-packages/tf2onnx/convert.py", line 714, in