tensorflow-onnx
tensorflow-onnx copied to clipboard
Segmentation fault core dump when converting tflite model to onnx
Describe the bug I am converting a tflite model to onnx with tf2onnx, but it causecore dump. The model is pose_detection.tflite, model link
System information
- OS Platform and Distribution: Linux Ubuntu 20.04
- Tensorflow Version: 2.6.0
- Python version: 3.7.0
- onnx version: 1.10.1
- tf2onnx version: 1.10.0/425d8 (installed with
pip install git+https://github.com/onnx/tensorflow-onnx
) - venv: anaconda3
I've also tried on windows10, with anaconda env, the same error.
To Reproduce
with the command line:
python -m tf2onnx.convert --tflite ./pose_detection.tflite --output pose_detection.onnx
Screenshots
If applicable, add screenshots to help explain your problem.
The chinese character in above image is "Segmentation fault (core dumped)"
Additional context The model is about human detection. model link
The model has the "densify" op which I haven't seen before. Seems to crash while trying to extract tensor data from tflite interpreter.
@TomWildenhain-Microsoft Thanks. I've convert the tflite model to saved_model format with tflite2tensorflow which support Densify op, and then convert the .pb file to onnx format.
Is there a plan to support the Densify
op in near future?
Hi @TomWildenhain-Microsoft, based on the result of my debugging, this repro code is crashed by this line. https://github.com/onnx/tensorflow-onnx/blob/a1a9343cef193ef45b7f91d511e9c7bd1dffb3e3/tf2onnx/tflite_utils.py#L200
Cause the _get_tensor_details()
function will catch the TensorSparsityParameters
of tflite interpreter. While TensorSparsityParameters
is missing in one of the tensor.
tensor_sparsity_params = self._interpreter.TensorSparsityParameters(tensor_index)
However, we don't use the tensor_sparsity_params
in details
. If I remove the above line in _get_tensor_details()
function. There will get the shape error.
cannot reshape array of size 96 into shape (16,1,1,24)
Do you have any idea about this case?