Jaesung Chung 17f94a78e8 Refactor reading builtin code in TFLite
This change is a preliminary work for resolving builtin code shortage problem.
It introduces a new utility build target, schema_utils, which will be used for
getting/setting builtin code operator value in TFLite flatbuffer in order to
have a single place to access actual fields for accessing values.

See also the RFC proposal draft,
https://github.com/tensorflow/community/pull/285

PiperOrigin-RevId: 335513647
Change-Id: I810a33425bbed3489cfe4a4a98a10dc4bd67a6ba
2020-10-05 15:36:21 -07:00

82 lines
1.8 KiB
Python

package(
default_visibility = [
"//visibility:public",
],
features = ["-parse_headers"],
licenses = ["notice"], # Apache 2.0
)
cc_binary(
name = "option_writer_generator",
srcs = ["option_writer_generator.cc"],
deps = [
"//tensorflow/lite/schema:schema_fbs_with_reflection",
"@flatbuffers",
],
)
cc_library(
name = "writer_lib",
srcs = [
"enum_mapping.h",
"writer_lib.cc",
],
hdrs = [
"writer_lib.h",
],
data = [
":option_writer_gen",
],
textual_hdrs = ["option_writer_generated.h"],
deps = [
"//tensorflow/lite:builtin_op_data",
"//tensorflow/lite:framework",
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/schema:schema_fbs_with_reflection",
"//tensorflow/lite/schema:schema_utils",
],
)
cc_binary(
name = "writer",
srcs = ["writer.cc"],
deps = [
":writer_lib",
"//tensorflow/lite:framework",
"//tensorflow/lite/kernels:builtin_ops",
],
)
cc_binary(
name = "writer_test",
srcs = ["writer_test.cc"],
deps = [
":writer_lib",
"//tensorflow/lite:framework",
"//tensorflow/lite/kernels:builtin_ops",
],
)
cc_test(
name = "writer_lib_test",
size = "small",
srcs = ["writer_lib_test.cc"],
deps = [
":writer_lib",
"//tensorflow/lite:framework",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/testing:util",
"@com_google_googletest//:gtest",
],
)
genrule(
name = "option_writer_gen",
outs = ["option_writer_generated.h"],
cmd = "$(location :option_writer_generator) $(@)",
tools = [":option_writer_generator"],
)