Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
TF Lite conversion of minimal graph with tf.matmul fails on Linux but works on MacOS #27640
Describe the current behavior
The code works on Mac, but fails on Linux during TF Lite conversion (see logs below).
Describe the expected behavior
I know that the TF Lite Operator Compatibility states:
This is not the case here, but it still curious that it works on Mac.
Code to reproduce the issue
Other info / logs
Output on Linux:
The error occurs during TF Lite conversion. The erroneous axis value (
@amitsrivastava78 Thank you for checking this out! I also have the same problem with Python3 (3.5.2) and tensorflow 1.13.1 (with or without gpu). Do you have a specific configuration issue in mind?
Since the error occurs on C++ level, I believe there might be an issue with system libraries then, rather than Python dependencies.
I don't think g++ is relevant either, since I installed tensorflow via pip, but for the sake of completeness this is the result of
@sklampfl , We can try one more thing, lets build the tensorflow from source(and install it) and then try to run the convert_test.py cases can check if you still face the same problem. If not then try to run the example code that you posted, i am pasting my configuration file(.tf_configure.bazelrc) as below , you already know my python and tensorflow configuration : -
build --action_env PYTHON_BIN_PATH="/usr/bin/python"
@amitsrivastava78 Thank you for investing your time in this.
I managed to get it to work on a fresh Ubuntu 18.04 instance, with Python 3.6.7 and TensorFlow compiled from source (both
It still does not work on my original Ubuntu 16.04 machine, even if I compile TensorFlow from source (Python 2 or Python 3). I have not yet figured out which configuration breaks it (e.g. gcc version? other libraries? exact Python version?).
I can work with Ubuntu 18.04 for now, but I think it is still a bug that some TFLite conversions only work under certain conditions.
PS: Thank you for pointing out the convert_test.py script. These test cases are always successful for me, regardless of whether the minimal test I posted fails or not.
Small code for reproducing:
import numpy as np import tensorflow as tf root = tf.train.Checkpoint() root.f = tf.function(lambda x, y: tf.matmul(x, y)) new_input_data = np.random.randn(2, 100, 100, 3).astype(np.float32) new_w = np.random.randn(2, 1, 3, 3).astype(np.float32) input_data = tf.convert_to_tensor(new_input_data) input_w = tf.convert_to_tensor(new_w) concrete_func = root.f.get_concrete_function(input_data, input_w) converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func]) tflite_model = converter.convert()
Do we have any workaround now?