| load("//tensorflow:tensorflow.bzl", "if_mlir_tflite", "py_binary", "tf_py_test") |
| |
| package( |
| default_visibility = [ |
| "//tensorflow/lite:__subpackages__", |
| "//tensorflow/tools/pip_package:__subpackages__", |
| ], |
| licenses = ["notice"], # Apache 2.0 |
| ) |
| |
| config_setting( |
| name = "tflite_convert_with_select_tf_ops", |
| define_values = {"tflite_convert_with_select_tf_ops": "true"}, |
| visibility = [ |
| "//tensorflow/lite:__subpackages__", |
| ], |
| ) |
| |
| filegroup( |
| name = "toco_python_api_hdrs", |
| srcs = [ |
| "toco_python_api.h", |
| ], |
| visibility = [ |
| "//tensorflow/python:__subpackages__", |
| ], |
| ) |
| |
| cc_library( |
| name = "toco_python_api", |
| srcs = ["toco_python_api.cc"], |
| hdrs = ["toco_python_api.h"], |
| defines = if_mlir_tflite( |
| if_false = [], |
| if_true = ["TFLITE_BUILD_WITH_MLIR_CONVERTER"], |
| ), |
| visibility = [ |
| "//tensorflow/python:__subpackages__", |
| ], |
| deps = [ |
| "//third_party/python_runtime:headers", |
| "//tensorflow/core:lib", |
| "//tensorflow/lite/python/interpreter_wrapper:python_utils", |
| "//tensorflow/lite/toco:model_flags_proto_cc", |
| "//tensorflow/lite/toco:toco_convert", |
| "//tensorflow/lite/toco:toco_flags_proto_cc", |
| "//tensorflow/lite/toco:toco_graphviz_dump_options", |
| "//tensorflow/lite/toco:toco_port", |
| "//tensorflow/lite/toco:toco_tooling", |
| "//tensorflow/core:protos_all_cc", |
| ] + select({ |
| # This is required when running `tflite_convert` from `bazel`. |
| # It requires to link with TensorFlow Ops to get the op definitions. |
| ":tflite_convert_with_select_tf_ops": [ |
| "//tensorflow/core:ops", |
| ], |
| "//conditions:default": [], |
| }) + if_mlir_tflite( |
| if_false = [], |
| if_true = ["//tensorflow/compiler/mlir/lite/python:graphdef_to_tfl_flatbuffer"], |
| ), |
| alwayslink = True, |
| ) |
| |
| # Compatibility stub. Remove when internal customers moved. |
| py_library( |
| name = "tensorflow_wrap_toco", |
| srcs = ["tensorflow_wrap_toco.py"], |
| visibility = [ |
| "//learning/expander/pod/deep_pod/utils:__subpackages__", |
| "//research/handwriting/converters/tflite:__subpackages__", |
| "//tensorflow/lite:__subpackages__", |
| ], |
| deps = [ |
| "//tensorflow/python:_pywrap_toco_api", |
| ], |
| ) |
| |
| py_binary( |
| name = "toco_from_protos", |
| srcs = ["toco_from_protos.py"], |
| python_version = "PY2", |
| srcs_version = "PY2AND3", |
| deps = [ |
| "//tensorflow/python:_pywrap_toco_api", |
| "//tensorflow/python:platform", |
| "//tensorflow/python:pywrap_tensorflow", |
| ], |
| ) |
| |
| tf_py_test( |
| name = "toco_from_protos_test", |
| srcs = ["toco_from_protos_test.py"], |
| additional_deps = [ |
| "//tensorflow:tensorflow_py", |
| "//tensorflow/lite/toco:model_flags_proto_py", |
| "//tensorflow/lite/toco:toco_flags_proto_py", |
| ], |
| tags = [ |
| "no_oss", |
| "no_pip", |
| ], |
| ) |