From 6411584e336b54f38c340a4dbc61733d8a2555a9 Mon Sep 17 00:00:00 2001 From: RJ Ascani Date: Fri, 27 Sep 2024 10:44:05 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"update=20the=20tensorflow.lite=20to?= =?UTF-8?q?=20use=20ai-edge-litert=20for=20all=20python=20based=E2=80=A6"?= =?UTF-8?q?=20(#2705)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts tensorflow/tflite-micro#2702 BUG=#2703 --- python/tflite_micro/BUILD | 1 - python/tflite_micro/runtime_test.py | 5 ++--- tensorflow/lite/micro/examples/hello_world/BUILD | 1 - tensorflow/lite/micro/examples/hello_world/evaluate.py | 5 ++--- tensorflow/lite/micro/examples/mnist_lstm/BUILD | 1 - .../lite/micro/examples/mnist_lstm/evaluate_test.py | 5 ++--- tensorflow/lite/micro/tools/BUILD | 2 -- tensorflow/lite/micro/tools/generate_test_for_model.py | 9 ++++----- tensorflow/lite/micro/tools/layer_by_layer_debugger.py | 3 +-- third_party/python_requirements.in | 1 - third_party/python_requirements.txt | 4 ---- 11 files changed, 11 insertions(+), 26 deletions(-) diff --git a/python/tflite_micro/BUILD b/python/tflite_micro/BUILD index 25f480c202e..4780b9a27ce 100644 --- a/python/tflite_micro/BUILD +++ b/python/tflite_micro/BUILD @@ -94,7 +94,6 @@ py_test( ], deps = [ ":runtime", - requirement("ai-edge-litert"), requirement("numpy"), requirement("tensorflow"), "//tensorflow/lite/micro/examples/recipes:add_four_numbers", diff --git a/python/tflite_micro/runtime_test.py b/python/tflite_micro/runtime_test.py index 6897ec0d5a6..2a9003c6b2c 100644 --- a/python/tflite_micro/runtime_test.py +++ b/python/tflite_micro/runtime_test.py @@ -25,7 +25,6 @@ import numpy as np import tensorflow as tf -from ai_edge_litert import interpreter as litert_interpreter from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tflite_micro.python.tflite_micro import runtime @@ -200,10 +199,10 @@ def testCompareWithTFLite(self): tflm_interpreter = runtime.Interpreter.from_bytes(model_data) # TFLite interpreter - tflite_interpreter = litert_interpreter.Interpreter( + tflite_interpreter = tf.lite.Interpreter( model_content=model_data, experimental_op_resolver_type=\ - litert_interpreter.OpResolverType.BUILTIN_REF) + tf.lite.experimental.OpResolverType.BUILTIN_REF) tflite_interpreter.allocate_tensors() tflite_output_details = tflite_interpreter.get_output_details()[0] tflite_input_details = tflite_interpreter.get_input_details()[0] diff --git a/tensorflow/lite/micro/examples/hello_world/BUILD b/tensorflow/lite/micro/examples/hello_world/BUILD index d327dc3545a..988b7dd6b62 100644 --- a/tensorflow/lite/micro/examples/hello_world/BUILD +++ b/tensorflow/lite/micro/examples/hello_world/BUILD @@ -53,7 +53,6 @@ py_binary( "@absl_py//absl:app", "@absl_py//absl/flags", "@absl_py//absl/logging", - requirement("ai-edge-litert"), requirement("numpy"), requirement("tensorflow"), "//python/tflite_micro:runtime", diff --git a/tensorflow/lite/micro/examples/hello_world/evaluate.py b/tensorflow/lite/micro/examples/hello_world/evaluate.py index f6f7ac1b62d..8b6f9488c11 100644 --- a/tensorflow/lite/micro/examples/hello_world/evaluate.py +++ b/tensorflow/lite/micro/examples/hello_world/evaluate.py @@ -16,7 +16,6 @@ import tensorflow as tf from absl import app from absl import flags -from ai_edge_litert import interpreter as litert_interpreter import numpy as np import matplotlib.pyplot as plt from tensorflow.python.platform import resource_loader @@ -93,9 +92,9 @@ def get_tflm_prediction(model_path, x_values): # returns the prediction of the interpreter. def get_tflite_prediction(model_path, x_values): # TFLite interpreter - tflite_interpreter = litert_interpreter.Interpreter( + tflite_interpreter = tf.lite.Interpreter( model_path=model_path, - experimental_op_resolver_type=litert_interpreter.OpResolverType. + experimental_op_resolver_type=tf.lite.experimental.OpResolverType. BUILTIN_REF, ) tflite_interpreter.allocate_tensors() diff --git a/tensorflow/lite/micro/examples/mnist_lstm/BUILD b/tensorflow/lite/micro/examples/mnist_lstm/BUILD index e8c5d2b66c9..7d818b21565 100644 --- a/tensorflow/lite/micro/examples/mnist_lstm/BUILD +++ b/tensorflow/lite/micro/examples/mnist_lstm/BUILD @@ -6,7 +6,6 @@ py_binary( srcs = ["train.py"], srcs_version = "PY3", deps = [ - requirement("ai-edge-litert"), requirement("numpy"), requirement("tensorflow"), ], diff --git a/tensorflow/lite/micro/examples/mnist_lstm/evaluate_test.py b/tensorflow/lite/micro/examples/mnist_lstm/evaluate_test.py index f5f0ad536fe..a7d74cd36ba 100644 --- a/tensorflow/lite/micro/examples/mnist_lstm/evaluate_test.py +++ b/tensorflow/lite/micro/examples/mnist_lstm/evaluate_test.py @@ -17,7 +17,6 @@ import numpy as np import tensorflow as tf -from ai_edge_litert import interpreter as litert_interpreter from tensorflow.python.framework import test_util from tensorflow.python.platform import resource_loader from tensorflow.python.platform import test @@ -44,10 +43,10 @@ def testInputErrHandling(self): evaluate.predict_image(self.tflm_interpreter, wrong_size_image_path) def testCompareWithTFLite(self): - tflite_interpreter = litert_interpreter.Interpreter( + tflite_interpreter = tf.lite.Interpreter( model_path=self.model_path, experimental_op_resolver_type=\ - litert_interpreter.OpResolverType.BUILTIN_REF) + tf.lite.experimental.OpResolverType.BUILTIN_REF) tflite_interpreter.allocate_tensors() tflite_output_details = tflite_interpreter.get_output_details()[0] tflite_input_details = tflite_interpreter.get_input_details()[0] diff --git a/tensorflow/lite/micro/tools/BUILD b/tensorflow/lite/micro/tools/BUILD index 4d1976e0a8e..2d1e1874280 100644 --- a/tensorflow/lite/micro/tools/BUILD +++ b/tensorflow/lite/micro/tools/BUILD @@ -34,7 +34,6 @@ py_library( srcs_version = "PY3", visibility = ["//:__subpackages__"], deps = [ - requirement("ai-edge-litert"), "//tensorflow/lite/python:schema_py", ], ) @@ -209,7 +208,6 @@ py_binary( ":model_transforms_utils", "@absl_py//absl:app", "@absl_py//absl/flags", - requirement("ai-edge-litert"), requirement("tensorflow"), "//python/tflite_micro:runtime", "//tensorflow/lite/tools:flatbuffer_utils", diff --git a/tensorflow/lite/micro/tools/generate_test_for_model.py b/tensorflow/lite/micro/tools/generate_test_for_model.py index 7bc77e959fb..8c5b4070c22 100644 --- a/tensorflow/lite/micro/tools/generate_test_for_model.py +++ b/tensorflow/lite/micro/tools/generate_test_for_model.py @@ -18,7 +18,6 @@ import numpy as np import tensorflow as tf -from ai_edge_litert import interpreter as litert_interpreter from tflite_micro.tensorflow.lite.python import schema_py_generated as schema_fb @@ -104,9 +103,9 @@ def generate_golden_single_in_single_out(self): if (len(self.model_paths) != 1): raise RuntimeError(f'Single model expected') model_path = self.model_paths[0] - interpreter = litert_interpreter.Interpreter(model_path=model_path, + interpreter = tf.lite.Interpreter(model_path=model_path, experimental_op_resolver_type=\ - litert_interpreter.OpResolverType.BUILTIN_REF) + tf.lite.experimental.OpResolverType.BUILTIN_REF) interpreter.allocate_tensors() @@ -141,10 +140,10 @@ def generate_goldens(self, builtin_operator): for model_path in self.model_paths: # Load model and run a single inference with random inputs. - interpreter = litert_interpreter.Interpreter( + interpreter = tf.lite.Interpreter( model_path=model_path, experimental_op_resolver_type=\ - litert_interpreter.OpResolverType.BUILTIN_REF) + tf.lite.experimental.OpResolverType.BUILTIN_REF) interpreter.allocate_tensors() input_tensor = interpreter.tensor( interpreter.get_input_details()[0]['index']) diff --git a/tensorflow/lite/micro/tools/layer_by_layer_debugger.py b/tensorflow/lite/micro/tools/layer_by_layer_debugger.py index 441f523f22c..8aa263b0c13 100644 --- a/tensorflow/lite/micro/tools/layer_by_layer_debugger.py +++ b/tensorflow/lite/micro/tools/layer_by_layer_debugger.py @@ -20,7 +20,6 @@ from absl import app from absl import flags from absl import logging -from ai_edge_litert import interpreter as litert_interpreter import numpy as np import tensorflow as tf @@ -195,7 +194,7 @@ def main(_) -> None: intrepreter_config=runtime.InterpreterConfig.kPreserveAllTensors, ) - tflite_interpreter = litert_interpreter.Interpreter( + tflite_interpreter = tf.lite.Interpreter( model_path=_INPUT_TFLITE_FILE.value, experimental_preserve_all_tensors=True, ) diff --git a/third_party/python_requirements.in b/third_party/python_requirements.in index d5a076c6dc1..29c081e5b18 100644 --- a/third_party/python_requirements.in +++ b/third_party/python_requirements.in @@ -34,4 +34,3 @@ mako pillow yapf protobuf -ai-edge-litert diff --git a/third_party/python_requirements.txt b/third_party/python_requirements.txt index 2aded403dc5..b0d91331ae0 100644 --- a/third_party/python_requirements.txt +++ b/third_party/python_requirements.txt @@ -11,9 +11,6 @@ absl-py==2.0.0 \ # keras # tensorboard # tensorflow -ai-edge-litert==1.0.1 \ - --hash=sha256:25a9b1577941498842bf77630722eda1163026c37abd57af66791a6955551b9d - # via -r third_party/python_requirements.in astunparse==1.6.3 \ --hash=sha256:5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872 \ --hash=sha256:c2652417f2c8b5bb325c885ae329bdf3f86424075c4fd1a128674bc6fba4b8e8 @@ -508,7 +505,6 @@ numpy==1.26.3 \ --hash=sha256:f73497e8c38295aaa4741bdfa4fda1a5aedda5473074369eca10626835445511 # via # -r third_party/python_requirements.in - # ai-edge-litert # h5py # keras # ml-dtypes