Skip to content

Commit

Permalink
Split getter and setter functions in schema utility files.
Browse files Browse the repository at this point in the history
This enables TFLite Micro to selectively include these setter functions in unit tests. The APIs used in creating the flatbuffer introduce new and delete symbols which can cause issues for libraries not fully building with --gc-sections in linker flags.

PiperOrigin-RevId: 339324965
Change-Id: I720b8dab6d80a94a47b7c8c427067966e2c42943
  • Loading branch information
Nick Kreeger authored and tensorflower-gardener committed Oct 27, 2020
1 parent 71aaef0 commit 48c3bae
Show file tree
Hide file tree
Showing 37 changed files with 172 additions and 107 deletions.
2 changes: 1 addition & 1 deletion tensorflow/compiler/mlir/lite/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ cc_library(
"//tensorflow/lite:string_util",
"//tensorflow/lite/delegates/flex:allowlisted_flex_ops_lib",
"//tensorflow/lite/kernels/internal:kernel_utils",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/tools/versioning",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/compiler/mlir/lite/flatbuffer_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ limitations under the License.
#include "tensorflow/core/platform/status.h"
#include "tensorflow/lite/delegates/flex/allowlisted_flex_ops.h"
#include "tensorflow/lite/kernels/internal/kernel_utils.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/string_util.h"
#include "tensorflow/lite/tools/versioning/op_version.h"
#include "tensorflow/lite/tools/versioning/runtime_version.h"
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/core/api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cc_test(
srcs = ["op_resolver_test.cc"],
deps = [
":api",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/schema:schema_conversion_utils",
"@com_google_googletest//:gtest",
],
)
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/core/api/op_resolver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
#include <cstring>

#include <gtest/gtest.h>
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"

namespace tflite {
namespace {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ cc_test(
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/kernels:kernel_util",
"//tensorflow/lite/kernels/internal:compatibility",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/testing:util",
"//third_party/eigen3",
"@com_google_googletest//:gtest",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/delegate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ limitations under the License.
#include "tensorflow/lite/kernels/internal/compatibility.h"
#include "tensorflow/lite/kernels/kernel_util.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/testing/util.h"
#include "tensorflow/lite/util.h"
#include "tensorflow/lite/version.h"
Expand Down
26 changes: 13 additions & 13 deletions tensorflow/lite/delegates/xnnpack/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@FP16",
"@com_google_googletest//:gtest",
"@flatbuffers",
Expand All @@ -94,8 +94,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@FP16",
"@com_google_googletest//:gtest",
"@flatbuffers",
Expand All @@ -112,8 +112,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@FP16",
"@com_google_googletest//:gtest",
"@flatbuffers",
Expand All @@ -130,8 +130,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@FP16",
"@com_google_googletest//:gtest",
"@flatbuffers",
Expand All @@ -148,8 +148,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -165,8 +165,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -182,8 +182,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -199,8 +199,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@FP16",
"@com_google_googletest//:gtest",
"@flatbuffers",
Expand All @@ -217,8 +217,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -234,8 +234,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -251,8 +251,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -268,8 +268,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand All @@ -285,8 +285,8 @@ cc_library(
"//tensorflow/lite:schema_fbs_version",
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@com_google_googletest//:gtest",
"@flatbuffers",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/conv_2d_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/leaky_relu_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/pad_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/pool_2d_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/prelu_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/reduce_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/reshape_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/delegates/xnnpack/softmax_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/version.h"

namespace tflite {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/kernels/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ cc_library(
"//tensorflow/lite/delegates/nnapi:nnapi_delegate",
"//tensorflow/lite/kernels/internal:tensor_utils",
"//tensorflow/lite/nnapi:nnapi_implementation",
"//tensorflow/lite/schema:schema_conversion_utils",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"//tensorflow/lite/testing:util",
"//tensorflow/lite/tools:command_line_flags",
"//tensorflow/lite/tools:logging",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/kernels/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ limitations under the License.
#include "tensorflow/lite/kernels/test_delegate_providers.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/nnapi/nnapi_implementation.h"
#include "tensorflow/lite/schema/schema_conversion_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"
#include "tensorflow/lite/string_type.h"
#include "tensorflow/lite/string_util.h"
#include "tensorflow/lite/tools/logging.h"
Expand Down
1 change: 0 additions & 1 deletion tensorflow/lite/micro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ cc_library(
"//tensorflow/lite/kernels/internal:compatibility",
"//tensorflow/lite/kernels/internal:tensor",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/schema:schema_utils",
"@flatbuffers//:runtime_cc",
],
)
Expand Down
3 changes: 2 additions & 1 deletion tensorflow/lite/micro/test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ limitations under the License.
#include "tensorflow/lite/micro/all_ops_resolver.h"
#include "tensorflow/lite/micro/micro_utils.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/schema/schema_utils.h"

// TODO(b/170464050): Use TFLM test only version of schema_utils.

namespace tflite {
namespace testing {
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/lite/micro/tools/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ tensorflow/lite/core/api/op_resolver.cc \
tensorflow/lite/core/api/tensor_utils.cc \
tensorflow/lite/kernels/internal/quantization_util.cc \
tensorflow/lite/kernels/kernel_util.cc \
tensorflow/lite/schema/schema_conversion_utils.cc \
tensorflow/lite/schema/schema_utils.cc

MICROLITE_CC_SRCS := $(filter-out $(MICROLITE_TEST_SRCS), $(MICROLITE_CC_BASE_SRCS))
Expand Down Expand Up @@ -308,6 +309,7 @@ tensorflow/lite/kernels/op_macros.h \
tensorflow/lite/kernels/padding.h \
tensorflow/lite/portable_type_to_tflitetype.h \
tensorflow/lite/schema/schema_generated.h \
tensorflow/lite/schema/schema_conversion_utils.h \
tensorflow/lite/schema/schema_utils.h \
tensorflow/lite/version.h

Expand Down
13 changes: 13 additions & 0 deletions tensorflow/lite/schema/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,17 @@ cc_library(
],
)

cc_library(
name = "schema_conversion_utils",
srcs = ["schema_conversion_utils.cc"],
hdrs = ["schema_conversion_utils.h"],
compatible_with = get_compatible_with_portable(),
visibility = [":utils_friends"],
deps = [
":schema_fbs",
"//tensorflow/lite/kernels/internal:compatibility",
"@flatbuffers",
],
)

tflite_portable_test_suite()
Loading

0 comments on commit 48c3bae

Please sign in to comment.