1load("//tensorflow:tensorflow.bzl", "py_binary", "tf_py_test") 2 3package( 4 default_visibility = [ 5 "//tensorflow/lite:__subpackages__", 6 "//tensorflow/tools/pip_package:__subpackages__", 7 ], 8 licenses = ["notice"], 9) 10 11config_setting( 12 name = "tflite_convert_with_select_tf_ops", 13 define_values = {"tflite_convert_with_select_tf_ops": "true"}, 14 visibility = [ 15 "//tensorflow/lite:__subpackages__", 16 ], 17) 18 19filegroup( 20 name = "toco_python_api_hdrs", 21 srcs = [ 22 "toco_python_api.h", 23 ], 24 visibility = [ 25 "//tensorflow/python:__subpackages__", 26 ], 27) 28 29cc_library( 30 name = "toco_python_api", 31 srcs = ["toco_python_api.cc"], 32 hdrs = ["toco_python_api.h"], 33 features = ["-parse_headers"], 34 visibility = [ 35 "//tensorflow/python:__subpackages__", 36 ], 37 deps = [ 38 "@com_google_protobuf//:protobuf_headers", 39 "//third_party/python_runtime:headers", # build_cleaner: keep; DNR: b/35864863 40 "//tensorflow/c:kernels", 41 "//tensorflow/core:protos_all_cc", 42 "//tensorflow/core:framework", 43 "//tensorflow/core:lib", 44 "//tensorflow/lite/c:common", 45 "//tensorflow/lite/core/api", 46 "//tensorflow/lite/python/interpreter_wrapper:python_utils", 47 "//tensorflow/lite/python/interpreter_wrapper:python_error_reporter", 48 "//tensorflow/lite/schema:schema_fbs", 49 "//tensorflow/lite/toco/logging:conversion_log_util", 50 "//tensorflow/lite/toco:model_flags_proto_cc", 51 "//tensorflow/lite/toco:toco_convert", 52 "//tensorflow/lite/toco/logging:toco_conversion_log_proto_cc", 53 "//tensorflow/lite/toco:toco_flags_proto_cc", 54 "//tensorflow/lite/toco:toco_graphviz_dump_options", 55 "//tensorflow/lite/toco:toco_port", 56 "//tensorflow/lite/toco:toco_tooling", 57 "//tensorflow/lite/toco:tooling_util", 58 "//tensorflow/compiler/mlir/lite/python:graphdef_to_tfl_flatbuffer", 59 "//tensorflow/compiler/mlir/lite/python:saved_model_to_tfl_flatbuffer", 60 "//tensorflow/compiler/mlir/lite/quantization/lite:quantize_model", 61 "//tensorflow/compiler/mlir/lite/sparsity:sparsify_model", 62 "//tensorflow/compiler/mlir/lite/metrics:error_collector", 63 "//tensorflow/lite/toco:types_proto_cc", 64 ] + select({ 65 # This is required when running `tflite_convert` from `bazel`. 66 # It requires to link with TensorFlow Ops to get the op definitions. 67 ":tflite_convert_with_select_tf_ops": [ 68 "//tensorflow/core:ops", 69 ], 70 "//conditions:default": [], 71 }), 72 alwayslink = True, 73) 74 75# Compatibility stub. Remove when internal customers moved. 76py_library( 77 name = "tensorflow_wrap_toco", 78 srcs = ["tensorflow_wrap_toco.py"], 79 srcs_version = "PY3", 80 visibility = [ 81 "//learning/expander/pod/deep_pod/utils:__subpackages__", 82 "//research/handwriting/converters/tflite:__subpackages__", 83 "//tensorflow/lite:__subpackages__", 84 ], 85 deps = [ 86 "//tensorflow/python:_pywrap_toco_api", 87 ], 88) 89 90py_binary( 91 name = "toco_from_protos", 92 srcs = ["toco_from_protos.py"], 93 python_version = "PY3", 94 srcs_version = "PY3", 95 deps = [ 96 "//tensorflow/python:_pywrap_toco_api", 97 "//tensorflow/python:platform", 98 "//tensorflow/python:pywrap_tensorflow", 99 "@absl_py//absl:app", 100 ], 101) 102 103tf_py_test( 104 name = "toco_from_protos_test", 105 srcs = ["toco_from_protos_test.py"], 106 python_version = "PY3", 107 tags = [ 108 "no_oss", 109 "no_pip", 110 ], 111 deps = [ 112 "//tensorflow:tensorflow_py", 113 "//tensorflow/lite/toco:model_flags_proto_py", 114 "//tensorflow/lite/toco:toco_flags_proto_py", 115 ], 116) 117