From 86868a156860877fc6e8c3393baf4942b6b7dbd4 Mon Sep 17 00:00:00 2001 From: Andrew Selle Date: Thu, 29 Mar 2018 07:59:46 -0700 Subject: [PATCH] Disable the toco binary in pip feature until it can used shared libs (#18061) * Disable the toco binary in pip feature until it can used shared libraries. The binary size was doubled by the saved model change. Since to process saved models most of the TensorFlow runtime is needed. A workaround to this is in the works and should be submitted in the next couple weeks. * Fix linter errors with unused tensorflow libs * Mollify the linter by removing os. --- tensorflow/contrib/lite/toco/python/BUILD | 3 --- tensorflow/contrib/lite/toco/python/toco_wrapper.py | 13 +++++++++---- tensorflow/tools/pip_package/build_pip_package.sh | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tensorflow/contrib/lite/toco/python/BUILD b/tensorflow/contrib/lite/toco/python/BUILD index 1711504..86d91bd 100644 --- a/tensorflow/contrib/lite/toco/python/BUILD +++ b/tensorflow/contrib/lite/toco/python/BUILD @@ -45,9 +45,6 @@ py_binary( name = "toco_wrapper", srcs = ["toco_wrapper.py"], srcs_version = "PY2AND3", - deps = [ - "//tensorflow:tensorflow_py", - ], ) tf_py_test( diff --git a/tensorflow/contrib/lite/toco/python/toco_wrapper.py b/tensorflow/contrib/lite/toco/python/toco_wrapper.py index e39b5f2..6d6b500 100644 --- a/tensorflow/contrib/lite/toco/python/toco_wrapper.py +++ b/tensorflow/contrib/lite/toco/python/toco_wrapper.py @@ -22,14 +22,19 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os import sys -import tensorflow as tf def main(): # Pip installs the binary in aux-bin off of main site-package install. # Just find it and exec, passing all arguments in the process. # TODO(aselle): it is unfortunate to use all of tensorflow to lookup binary. - binary = os.path.join(tf.__path__[0], 'aux-bin/toco') - os.execvp(binary, sys.argv) + print("""TOCO from pip install is currently not working on command line. +Please use the python TOCO API or use +bazel run tensorflow/contrib/lite:toco -- from a TensorFlow source dir. +""") + sys.exit(1) + # TODO(aselle): Replace this when we find a way to run toco without + # blowing up executable size. + # binary = os.path.join(tf.__path__[0], 'aux-bin/toco') + # os.execvp(binary, sys.argv) diff --git a/tensorflow/tools/pip_package/build_pip_package.sh b/tensorflow/tools/pip_package/build_pip_package.sh index dc31e4c..feb3114 100755 --- a/tensorflow/tools/pip_package/build_pip_package.sh +++ b/tensorflow/tools/pip_package/build_pip_package.sh @@ -139,7 +139,9 @@ function main() { fi mkdir "${TMPDIR}/tensorflow/aux-bin" # Install toco as a binary in aux-bin. - cp bazel-bin/tensorflow/contrib/lite/toco/toco ${TMPDIR}/tensorflow/aux-bin/ + # TODO(aselle): Re-enable this when we find a way to do it without doubling + # the whl size (over the limit). + # cp bazel-bin/tensorflow/contrib/lite/toco/toco ${TMPDIR}/tensorflow/aux-bin/ fi # protobuf pip package doesn't ship with header files. Copy the headers -- 2.7.4