Reorganizing tfl schema.

PiperOrigin-RevId: 630425831
This commit is contained in:
A. Unique TensorFlower 2024-05-03 10:18:06 -07:00 committed by TensorFlower Gardener
parent 0a559b427a
commit d63ef0dca2
20 changed files with 1708 additions and 34 deletions

View File

@ -362,6 +362,7 @@ cc_library(
":tensorflow_lite_ops_inc_gen",
":tensorflow_lite_passes_inc_gen",
"//tensorflow/compiler/mlir/lite/quantization/ir:QuantOps",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib:quantization_config",
"//tensorflow/compiler/mlir/tensorflow",
@ -371,7 +372,6 @@ cc_library(
"//tensorflow/compiler/mlir/tensorflow:tensorflow_traits",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"//tensorflow/core:framework",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
@ -704,6 +704,7 @@ cc_library(
":variables_utils",
"//tensorflow/compiler/mlir:op_or_arg_name_mapper",
"//tensorflow/compiler/mlir/lite/quantization/ir:QuantOps",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/lite/stablehlo:optimize_layout",
"//tensorflow/compiler/mlir/lite/stablehlo:tf_legalize_hlo",
"//tensorflow/compiler/mlir/lite/stablehlo:tfl_legalize_hlo",
@ -728,7 +729,6 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/kernels:tensor_list",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/container:inlined_vector",
@ -871,6 +871,7 @@ cc_library(
":validators",
"//tensorflow/compiler/mlir/lite/quantization/ir:QuantOps",
"//tensorflow/compiler/mlir/lite/quantization/lite:tfl_to_std",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/quantization/common:uniform_quantized_types",
"//tensorflow/compiler/mlir/quantization/common/ir:QuantOps",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib",
@ -879,7 +880,6 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/platform:logging",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/tools/optimize:operator_property",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/memory",
@ -1025,6 +1025,7 @@ cc_library(
":convert_type",
":converter_inc",
":tensorflow_lite",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/tensorflow:dynamic_shape_utils",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"//tensorflow/core/platform:errors",
@ -1032,7 +1033,6 @@ cc_library(
"//tensorflow/core/platform:statusor",
"//tensorflow/lite/core/c:private_common",
"//tensorflow/lite/kernels/internal:kernel_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_fbs_with_mutable",
"//tensorflow/lite/schema:schema_utils",
"@com_google_absl//absl/container:flat_hash_map",
@ -1065,7 +1065,7 @@ tf_native_cc_binary(
name = "json_to_flatbuffer",
srcs = ["json_to_flatbuffer.cc"],
deps = [
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"@flatbuffers",
],
)
@ -1210,10 +1210,10 @@ cc_library(
],
deps = [
":tensorflow_lite",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/platform:errors",
"//tensorflow/lite/schema:schema_fbs",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Support",
"@local_xla//xla:statusor",
@ -1232,8 +1232,8 @@ cc_library(
":flatbuffer_export",
":flatbuffer_import",
"//tensorflow/compiler/mlir:op_or_arg_name_mapper",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/core:protos_all_cc",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/toco:toco_flags_proto_cc",
"@com_google_absl//absl/strings",
"@llvm-project//mlir:FuncDialect",
@ -1322,6 +1322,7 @@ tf_cc_binary(
":tf_to_tfl_flatbuffer",
"//tensorflow/cc/saved_model:loader",
"//tensorflow/compiler/mlir:init_mlir",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib:quantization_config",
"//tensorflow/compiler/mlir/tensorflow",
"//tensorflow/compiler/mlir/tensorflow:mlir_roundtrip_flags",
@ -1332,7 +1333,6 @@ tf_cc_binary(
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/platform:errors",
"//tensorflow/lite:framework",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
@ -1430,6 +1430,7 @@ cc_library(
"//tensorflow/compiler/mlir/lite/metrics:error_collector",
"//tensorflow/compiler/mlir/lite/metrics:error_collector_inst",
"//tensorflow/compiler/mlir/lite/quantization/stablehlo:quantization",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/lite/stablehlo:legalize_stablehlo_composite_to_tfl_custom",
"//tensorflow/compiler/mlir/lite/stablehlo:legalize_stablehlo_to_vhlo_pass",
"//tensorflow/compiler/mlir/lite/stablehlo:op_stat_pass",
@ -1456,7 +1457,6 @@ cc_library(
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/experimental/remat:metadata_util",
"//tensorflow/lite/python/metrics:converter_error_data_proto_cc",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/toco:toco_flags_proto_cc",
"//tensorflow/lite/tools/optimize:quantize_weights",
"//tensorflow/lite/tools/optimize:reduced_precision_support",
@ -1505,11 +1505,11 @@ cc_library(
deps = [
":convert_type",
":low_bit_utils",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/tensorflow:dynamic_shape_utils",
"//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
"//tensorflow/core:protos_all_cc",
"//tensorflow/lite:string_util",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/base",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",

View File

@ -34,10 +34,10 @@ limitations under the License.
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops_dialect.h.inc"
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops_enums.h.inc"
#include "tensorflow/compiler/mlir/lite/quantization/ir/QuantOps.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/compiler/mlir/lite/utils/utils.h"
#include "tensorflow/compiler/mlir/quantization/common/quantization_lib/quantization_utils.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_traits.h"
#include "tensorflow/lite/schema/schema_generated.h"
#define GET_ATTRDEF_CLASSES
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops_attrdefs.h.inc"

View File

@ -22,7 +22,6 @@ limitations under the License.
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
#include "flatbuffers/idl.h" // from @flatbuffers
#include "flatbuffers/util.h" // from @flatbuffers
#include "tensorflow/lite/schema/schema_generated.h"
int main(int argc, char** argv) {
// load FlatBuffer schema (.fbs) and JSON from disk

View File

@ -31,13 +31,13 @@ cc_library(
"//tensorflow/compiler/mlir/lite:flatbuffer_translate_lib",
"//tensorflow/compiler/mlir/lite:tensorflow_lite",
"//tensorflow/compiler/mlir/lite:tf_tfl_passes",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib:quantization_config",
"//tensorflow/compiler/mlir/tensorflow:error_util",
"//tensorflow/core:protos_all_cc",
"//tensorflow/lite:framework",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/core/api",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"@llvm-project//llvm:Support",
@ -60,13 +60,13 @@ cc_library(
"//tensorflow/compiler/mlir/lite:flatbuffer_translate_lib",
"//tensorflow/compiler/mlir/lite:tensorflow_lite",
"//tensorflow/compiler/mlir/lite:tf_tfl_passes",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/quantization/common/quantization_lib:quantization_config",
"//tensorflow/compiler/mlir/tensorflow:error_util",
"//tensorflow/core:protos_all_cc",
"//tensorflow/lite:framework",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/core/api",
"//tensorflow/lite/schema:schema_fbs",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"@flatbuffers//:runtime_cc",
@ -113,9 +113,9 @@ tf_cc_binary(
],
deps = [
":quantize_model",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/lite:framework",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/schema:schema_fbs",
"@llvm-project//llvm:Support",
],
)
@ -164,13 +164,13 @@ tf_cc_test(
],
deps = [
":quantize_model",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/lite:framework",
"//tensorflow/lite:string",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/core/api:error_reporter",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/tools/optimize:test_util",
"@com_google_absl//absl/container:flat_hash_set",
@ -202,11 +202,11 @@ tf_cc_test(
],
deps = [
":quantize_weights",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/lite:framework",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/tools/optimize:test_util",
"@com_google_googletest//:gtest",

View File

@ -30,6 +30,7 @@ limitations under the License.
#include "absl/container/flat_hash_set.h"
#include "flatbuffers/flatbuffer_builder.h" // from @flatbuffers
#include "flatbuffers/vector.h" // from @flatbuffers
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/path.h"
#include "tensorflow/core/platform/types.h"
@ -37,7 +38,6 @@ limitations under the License.
#include "tensorflow/lite/c/c_api_types.h"
#include "tensorflow/lite/core/api/error_reporter.h"
#include "tensorflow/lite/model_builder.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/string_type.h"
#include "tensorflow/lite/tools/optimize/test_util.h"

View File

@ -22,8 +22,8 @@ limitations under the License.
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "tensorflow/compiler/mlir/lite/quantization/lite/quantize_model.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/lite/c/c_api_types.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/stderr_reporter.h"
using llvm::cl::opt;

View File

@ -0,0 +1,20 @@
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
default_visibility = [
"//visibility:public",
],
licenses = ["notice"],
)
exports_files(
srcs = ["schema.fbs"],
)
flatbuffer_cc_library(
name = "schema_fbs",
srcs = ["schema.fbs"],
compatible_with = get_compatible_with_portable(),
)

View File

@ -0,0 +1,2 @@
This directory contains schema related files and targets that are used by both
the TFL converter (tf/compiler/mlir/lite/) and the runtime (tf/lite/).

File diff suppressed because it is too large Load Diff

View File

@ -30,12 +30,12 @@ cc_library(
"//tensorflow/compiler/mlir/lite:common",
"//tensorflow/compiler/mlir/lite:flatbuffer_translate_lib",
"//tensorflow/compiler/mlir/lite:tensorflow_lite_d2s",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/compiler/mlir/tensorflow:error_util",
"//tensorflow/core:protos_all_cc",
"//tensorflow/lite:framework",
"//tensorflow/lite/core/api",
"//tensorflow/lite/core/c:private_c_api_types",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/tools/optimize:reduced_precision_support",
"@com_google_absl//absl/strings",
"@flatbuffers",
@ -54,10 +54,10 @@ tf_cc_test(
],
deps = [
":sparsify_model",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/lite/core:model_builder",
"//tensorflow/lite/core/api:error_reporter",
"//tensorflow/lite/core/c:private_c_api_types",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/tools/optimize:reduced_precision_support",
"@com_google_googletest//:gtest_main",
"@flatbuffers",

View File

@ -26,10 +26,10 @@ limitations under the License.
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "flatbuffers/flatbuffer_builder.h" // from @flatbuffers
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/lite/core/api/error_reporter.h"
#include "tensorflow/lite/core/c/c_api_types.h"
#include "tensorflow/lite/core/model_builder.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/tools/optimize/reduced_precision_support.h"
namespace mlir {

View File

@ -56,8 +56,8 @@ tf_native_cc_binary(
"importer_test_min_max.cc",
],
deps = [
"//tensorflow/compiler/mlir/lite/schema:schema_fbs",
"//tensorflow/lite:framework",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_absl//absl/strings",
"@llvm-project//llvm:Support",

View File

@ -24,8 +24,8 @@ limitations under the License.
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
using llvm::cl::opt;

View File

@ -49,6 +49,7 @@ limitations under the License.
#include "tensorflow/compiler/mlir/init_mlir.h"
#include "tensorflow/compiler/mlir/lite/common/tfl_pass_config.h"
#include "tensorflow/compiler/mlir/lite/flatbuffer_export_flags.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/compiler/mlir/lite/tf_tfl_translate_cl.h"
#include "tensorflow/compiler/mlir/lite/tf_to_tfl_flatbuffer.h"
#include "tensorflow/compiler/mlir/lite/transforms/passes.h"
@ -61,7 +62,6 @@ limitations under the License.
#include "tensorflow/core/platform/errors.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/lite/model_builder.h"
#include "tensorflow/lite/schema/schema_generated.h"
using mlir::MLIRContext;
using mlir::ModuleOp;

View File

@ -50,6 +50,7 @@ limitations under the License.
#include "tensorflow/compiler/mlir/lite/metrics/error_collector.h"
#include "tensorflow/compiler/mlir/lite/metrics/error_collector_inst.h"
#include "tensorflow/compiler/mlir/lite/quantization/stablehlo/quantization.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/compiler/mlir/lite/stablehlo/transforms/op_stat_pass.h"
#include "tensorflow/compiler/mlir/lite/stablehlo/transforms/passes.h"
#include "tensorflow/compiler/mlir/lite/stablehlo/transforms/stablehlo_util.h"
@ -80,7 +81,6 @@ limitations under the License.
#include "tensorflow/lite/c/c_api_types.h"
#include "tensorflow/lite/experimental/remat/metadata_util.h"
#include "tensorflow/lite/python/metrics/converter_error_data.pb.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/tools/optimize/quantize_weights.h"
#include "tensorflow/lite/tools/optimize/reduced_precision_support.h"
#include "tsl/platform/protobuf.h" // IWYU pragma: keep

View File

@ -40,13 +40,13 @@ limitations under the License.
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h"
#include "tensorflow/compiler/mlir/lite/quantization/ir/QuantOps.h"
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "tensorflow/compiler/mlir/quantization/common/ir/FakeQuantSupport.h"
#include "tensorflow/compiler/mlir/quantization/common/quantization_lib/quantization_config.h"
#include "tensorflow/compiler/mlir/quantization/common/quantization_lib/quantization_traits.h"
#include "tensorflow/compiler/mlir/quantization/common/quantization_lib/quantization_utils.h"
#include "tensorflow/compiler/mlir/quantization/common/uniform_quantized_types.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/tools/optimize/operator_property.h"
//===----------------------------------------------------------------------===//

View File

@ -19,9 +19,9 @@ limitations under the License.
#include "mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/IR/Types.h" // from @llvm-project
#include "mlir/IR/Value.h" // from @llvm-project
#include "tensorflow/compiler/mlir/lite/schema/schema_generated.h"
#include "xla/statusor.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/lite/schema/schema_generated.h"
namespace mlir {
class Builder;

View File

@ -1102,10 +1102,10 @@ void* FlexSinhInit(TfLiteOpaqueContext* context, const char* buffer,
size_t length) {
auto sinh_params = new SinhParams;
// The buffer that is passed into here is the custom_options
// field from the flatbuffer (tensorflow/lite/schema/schema.fbs)
// `Operator` for this node.
// Typically it should be stored as a FlexBuffer, but for this test
// we assume that it is just a string.
// field from the flatbuffer
// (third_party/tensorflow/compiler/mlir/lite/schema/schema.fbs) `Operator`
// for this node. Typically it should be stored as a FlexBuffer, but for this
// test we assume that it is just a string.
if (std::string(buffer, length) == "use_cosh") {
sinh_params->use_cosh_instead = true;
}

View File

@ -115,7 +115,7 @@ exports_files([
flatbuffer_cc_library(
name = "schema_fbs",
srcs = ["schema.fbs"],
srcs = ["//tensorflow/compiler/mlir/lite/schema:schema.fbs"],
compatible_with = get_compatible_with_portable(),
)

View File

@ -195,7 +195,7 @@ def flatbuffer_cc_library(
reflection binaries for the schemas.
'''
output_headers = [
(out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1])
(out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1].split(":")[-1])
for s in srcs
]
reflection_name = "%s_reflection" % name if gen_reflections else ""