Skip to content

Commit 48c3bae

Browse files
Nick Kreegertensorflower-gardener
Nick Kreeger
authored andcommitted
Split getter and setter functions in schema utility files.
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
1 parent 71aaef0 commit 48c3bae

37 files changed

+172
-107
lines changed

tensorflow/compiler/mlir/lite/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ cc_library(
671671
"//tensorflow/lite:string_util",
672672
"//tensorflow/lite/delegates/flex:allowlisted_flex_ops_lib",
673673
"//tensorflow/lite/kernels/internal:kernel_utils",
674+
"//tensorflow/lite/schema:schema_conversion_utils",
674675
"//tensorflow/lite/schema:schema_fbs",
675-
"//tensorflow/lite/schema:schema_utils",
676676
"//tensorflow/lite/tools/versioning",
677677
"@com_google_absl//absl/base:core_headers",
678678
"@com_google_absl//absl/container:flat_hash_map",

tensorflow/compiler/mlir/lite/flatbuffer_export.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ limitations under the License.
7474
#include "tensorflow/core/platform/status.h"
7575
#include "tensorflow/lite/delegates/flex/allowlisted_flex_ops.h"
7676
#include "tensorflow/lite/kernels/internal/kernel_utils.h"
77+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
7778
#include "tensorflow/lite/schema/schema_generated.h"
78-
#include "tensorflow/lite/schema/schema_utils.h"
7979
#include "tensorflow/lite/string_util.h"
8080
#include "tensorflow/lite/tools/versioning/op_version.h"
8181
#include "tensorflow/lite/tools/versioning/runtime_version.h"

tensorflow/lite/core/api/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ cc_test(
9797
srcs = ["op_resolver_test.cc"],
9898
deps = [
9999
":api",
100-
"//tensorflow/lite/schema:schema_utils",
100+
"//tensorflow/lite/schema:schema_conversion_utils",
101101
"@com_google_googletest//:gtest",
102102
],
103103
)

tensorflow/lite/core/api/op_resolver_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
#include <cstring>
1919

2020
#include <gtest/gtest.h>
21-
#include "tensorflow/lite/schema/schema_utils.h"
21+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
2222

2323
namespace tflite {
2424
namespace {

tensorflow/lite/delegates/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ cc_test(
8585
"//tensorflow/lite/kernels:builtin_ops",
8686
"//tensorflow/lite/kernels:kernel_util",
8787
"//tensorflow/lite/kernels/internal:compatibility",
88+
"//tensorflow/lite/schema:schema_conversion_utils",
8889
"//tensorflow/lite/schema:schema_fbs",
89-
"//tensorflow/lite/schema:schema_utils",
9090
"//tensorflow/lite/testing:util",
9191
"//third_party/eigen3",
9292
"@com_google_googletest//:gtest",

tensorflow/lite/delegates/delegate_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ limitations under the License.
3030
#include "tensorflow/lite/kernels/internal/compatibility.h"
3131
#include "tensorflow/lite/kernels/kernel_util.h"
3232
#include "tensorflow/lite/kernels/register.h"
33+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3334
#include "tensorflow/lite/schema/schema_generated.h"
34-
#include "tensorflow/lite/schema/schema_utils.h"
3535
#include "tensorflow/lite/testing/util.h"
3636
#include "tensorflow/lite/util.h"
3737
#include "tensorflow/lite/version.h"

tensorflow/lite/delegates/xnnpack/BUILD

+13-13
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ cc_library(
7676
"//tensorflow/lite:schema_fbs_version",
7777
"//tensorflow/lite/c:common",
7878
"//tensorflow/lite/kernels:builtin_ops",
79+
"//tensorflow/lite/schema:schema_conversion_utils",
7980
"//tensorflow/lite/schema:schema_fbs",
80-
"//tensorflow/lite/schema:schema_utils",
8181
"@FP16",
8282
"@com_google_googletest//:gtest",
8383
"@flatbuffers",
@@ -94,8 +94,8 @@ cc_library(
9494
"//tensorflow/lite:schema_fbs_version",
9595
"//tensorflow/lite/c:common",
9696
"//tensorflow/lite/kernels:builtin_ops",
97+
"//tensorflow/lite/schema:schema_conversion_utils",
9798
"//tensorflow/lite/schema:schema_fbs",
98-
"//tensorflow/lite/schema:schema_utils",
9999
"@FP16",
100100
"@com_google_googletest//:gtest",
101101
"@flatbuffers",
@@ -112,8 +112,8 @@ cc_library(
112112
"//tensorflow/lite:schema_fbs_version",
113113
"//tensorflow/lite/c:common",
114114
"//tensorflow/lite/kernels:builtin_ops",
115+
"//tensorflow/lite/schema:schema_conversion_utils",
115116
"//tensorflow/lite/schema:schema_fbs",
116-
"//tensorflow/lite/schema:schema_utils",
117117
"@FP16",
118118
"@com_google_googletest//:gtest",
119119
"@flatbuffers",
@@ -130,8 +130,8 @@ cc_library(
130130
"//tensorflow/lite:schema_fbs_version",
131131
"//tensorflow/lite/c:common",
132132
"//tensorflow/lite/kernels:builtin_ops",
133+
"//tensorflow/lite/schema:schema_conversion_utils",
133134
"//tensorflow/lite/schema:schema_fbs",
134-
"//tensorflow/lite/schema:schema_utils",
135135
"@FP16",
136136
"@com_google_googletest//:gtest",
137137
"@flatbuffers",
@@ -148,8 +148,8 @@ cc_library(
148148
"//tensorflow/lite:schema_fbs_version",
149149
"//tensorflow/lite/c:common",
150150
"//tensorflow/lite/kernels:builtin_ops",
151+
"//tensorflow/lite/schema:schema_conversion_utils",
151152
"//tensorflow/lite/schema:schema_fbs",
152-
"//tensorflow/lite/schema:schema_utils",
153153
"@com_google_googletest//:gtest",
154154
"@flatbuffers",
155155
],
@@ -165,8 +165,8 @@ cc_library(
165165
"//tensorflow/lite:schema_fbs_version",
166166
"//tensorflow/lite/c:common",
167167
"//tensorflow/lite/kernels:builtin_ops",
168+
"//tensorflow/lite/schema:schema_conversion_utils",
168169
"//tensorflow/lite/schema:schema_fbs",
169-
"//tensorflow/lite/schema:schema_utils",
170170
"@com_google_googletest//:gtest",
171171
"@flatbuffers",
172172
],
@@ -182,8 +182,8 @@ cc_library(
182182
"//tensorflow/lite:schema_fbs_version",
183183
"//tensorflow/lite/c:common",
184184
"//tensorflow/lite/kernels:builtin_ops",
185+
"//tensorflow/lite/schema:schema_conversion_utils",
185186
"//tensorflow/lite/schema:schema_fbs",
186-
"//tensorflow/lite/schema:schema_utils",
187187
"@com_google_googletest//:gtest",
188188
"@flatbuffers",
189189
],
@@ -199,8 +199,8 @@ cc_library(
199199
"//tensorflow/lite:schema_fbs_version",
200200
"//tensorflow/lite/c:common",
201201
"//tensorflow/lite/kernels:builtin_ops",
202+
"//tensorflow/lite/schema:schema_conversion_utils",
202203
"//tensorflow/lite/schema:schema_fbs",
203-
"//tensorflow/lite/schema:schema_utils",
204204
"@FP16",
205205
"@com_google_googletest//:gtest",
206206
"@flatbuffers",
@@ -217,8 +217,8 @@ cc_library(
217217
"//tensorflow/lite:schema_fbs_version",
218218
"//tensorflow/lite/c:common",
219219
"//tensorflow/lite/kernels:builtin_ops",
220+
"//tensorflow/lite/schema:schema_conversion_utils",
220221
"//tensorflow/lite/schema:schema_fbs",
221-
"//tensorflow/lite/schema:schema_utils",
222222
"@com_google_googletest//:gtest",
223223
"@flatbuffers",
224224
],
@@ -234,8 +234,8 @@ cc_library(
234234
"//tensorflow/lite:schema_fbs_version",
235235
"//tensorflow/lite/c:common",
236236
"//tensorflow/lite/kernels:builtin_ops",
237+
"//tensorflow/lite/schema:schema_conversion_utils",
237238
"//tensorflow/lite/schema:schema_fbs",
238-
"//tensorflow/lite/schema:schema_utils",
239239
"@com_google_googletest//:gtest",
240240
"@flatbuffers",
241241
],
@@ -251,8 +251,8 @@ cc_library(
251251
"//tensorflow/lite:schema_fbs_version",
252252
"//tensorflow/lite/c:common",
253253
"//tensorflow/lite/kernels:builtin_ops",
254+
"//tensorflow/lite/schema:schema_conversion_utils",
254255
"//tensorflow/lite/schema:schema_fbs",
255-
"//tensorflow/lite/schema:schema_utils",
256256
"@com_google_googletest//:gtest",
257257
"@flatbuffers",
258258
],
@@ -268,8 +268,8 @@ cc_library(
268268
"//tensorflow/lite:schema_fbs_version",
269269
"//tensorflow/lite/c:common",
270270
"//tensorflow/lite/kernels:builtin_ops",
271+
"//tensorflow/lite/schema:schema_conversion_utils",
271272
"//tensorflow/lite/schema:schema_fbs",
272-
"//tensorflow/lite/schema:schema_utils",
273273
"@com_google_googletest//:gtest",
274274
"@flatbuffers",
275275
],
@@ -285,8 +285,8 @@ cc_library(
285285
"//tensorflow/lite:schema_fbs_version",
286286
"//tensorflow/lite/c:common",
287287
"//tensorflow/lite/kernels:builtin_ops",
288+
"//tensorflow/lite/schema:schema_conversion_utils",
288289
"//tensorflow/lite/schema:schema_fbs",
289-
"//tensorflow/lite/schema:schema_utils",
290290
"@com_google_googletest//:gtest",
291291
"@flatbuffers",
292292
],

tensorflow/lite/delegates/xnnpack/binary_elementwise_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ limitations under the License.
2828
#include "tensorflow/lite/interpreter.h"
2929
#include "tensorflow/lite/kernels/register.h"
3030
#include "tensorflow/lite/model.h"
31+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3132
#include "tensorflow/lite/schema/schema_generated.h"
32-
#include "tensorflow/lite/schema/schema_utils.h"
3333
#include "tensorflow/lite/version.h"
3434

3535
namespace tflite {

tensorflow/lite/delegates/xnnpack/conv_2d_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/depthwise_conv_2d_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/fully_connected_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ limitations under the License.
2828
#include "tensorflow/lite/interpreter.h"
2929
#include "tensorflow/lite/kernels/register.h"
3030
#include "tensorflow/lite/model.h"
31+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3132
#include "tensorflow/lite/schema/schema_generated.h"
32-
#include "tensorflow/lite/schema/schema_utils.h"
3333
#include "tensorflow/lite/version.h"
3434

3535
namespace tflite {

tensorflow/lite/delegates/xnnpack/leaky_relu_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/pad_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/pool_2d_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ limitations under the License.
2626
#include "tensorflow/lite/interpreter.h"
2727
#include "tensorflow/lite/kernels/register.h"
2828
#include "tensorflow/lite/model.h"
29+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
2930
#include "tensorflow/lite/schema/schema_generated.h"
30-
#include "tensorflow/lite/schema/schema_utils.h"
3131
#include "tensorflow/lite/version.h"
3232

3333
namespace tflite {

tensorflow/lite/delegates/xnnpack/prelu_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ limitations under the License.
2828
#include "tensorflow/lite/interpreter.h"
2929
#include "tensorflow/lite/kernels/register.h"
3030
#include "tensorflow/lite/model.h"
31+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3132
#include "tensorflow/lite/schema/schema_generated.h"
32-
#include "tensorflow/lite/schema/schema_utils.h"
3333
#include "tensorflow/lite/version.h"
3434

3535
namespace tflite {

tensorflow/lite/delegates/xnnpack/reduce_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/reshape_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/resize_bilinear_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/softmax_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/delegates/xnnpack/unary_elementwise_tester.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ limitations under the License.
2727
#include "tensorflow/lite/interpreter.h"
2828
#include "tensorflow/lite/kernels/register.h"
2929
#include "tensorflow/lite/model.h"
30+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
3031
#include "tensorflow/lite/schema/schema_generated.h"
31-
#include "tensorflow/lite/schema/schema_utils.h"
3232
#include "tensorflow/lite/version.h"
3333

3434
namespace tflite {

tensorflow/lite/kernels/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ cc_library(
190190
"//tensorflow/lite/delegates/nnapi:nnapi_delegate",
191191
"//tensorflow/lite/kernels/internal:tensor_utils",
192192
"//tensorflow/lite/nnapi:nnapi_implementation",
193+
"//tensorflow/lite/schema:schema_conversion_utils",
193194
"//tensorflow/lite/schema:schema_fbs",
194-
"//tensorflow/lite/schema:schema_utils",
195195
"//tensorflow/lite/testing:util",
196196
"//tensorflow/lite/tools:command_line_flags",
197197
"//tensorflow/lite/tools:logging",

tensorflow/lite/kernels/test_util.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ limitations under the License.
4343
#include "tensorflow/lite/kernels/test_delegate_providers.h"
4444
#include "tensorflow/lite/model.h"
4545
#include "tensorflow/lite/nnapi/nnapi_implementation.h"
46+
#include "tensorflow/lite/schema/schema_conversion_utils.h"
4647
#include "tensorflow/lite/schema/schema_generated.h"
47-
#include "tensorflow/lite/schema/schema_utils.h"
4848
#include "tensorflow/lite/string_type.h"
4949
#include "tensorflow/lite/string_util.h"
5050
#include "tensorflow/lite/tools/logging.h"

tensorflow/lite/micro/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ cc_library(
8888
"//tensorflow/lite/kernels/internal:compatibility",
8989
"//tensorflow/lite/kernels/internal:tensor",
9090
"//tensorflow/lite/schema:schema_fbs",
91-
"//tensorflow/lite/schema:schema_utils",
9291
"@flatbuffers//:runtime_cc",
9392
],
9493
)

tensorflow/lite/micro/test_helpers.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ limitations under the License.
3030
#include "tensorflow/lite/micro/all_ops_resolver.h"
3131
#include "tensorflow/lite/micro/micro_utils.h"
3232
#include "tensorflow/lite/schema/schema_generated.h"
33-
#include "tensorflow/lite/schema/schema_utils.h"
33+
34+
// TODO(b/170464050): Use TFLM test only version of schema_utils.
3435

3536
namespace tflite {
3637
namespace testing {

tensorflow/lite/micro/tools/make/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ tensorflow/lite/core/api/op_resolver.cc \
232232
tensorflow/lite/core/api/tensor_utils.cc \
233233
tensorflow/lite/kernels/internal/quantization_util.cc \
234234
tensorflow/lite/kernels/kernel_util.cc \
235+
tensorflow/lite/schema/schema_conversion_utils.cc \
235236
tensorflow/lite/schema/schema_utils.cc
236237

237238
MICROLITE_CC_SRCS := $(filter-out $(MICROLITE_TEST_SRCS), $(MICROLITE_CC_BASE_SRCS))
@@ -308,6 +309,7 @@ tensorflow/lite/kernels/op_macros.h \
308309
tensorflow/lite/kernels/padding.h \
309310
tensorflow/lite/portable_type_to_tflitetype.h \
310311
tensorflow/lite/schema/schema_generated.h \
312+
tensorflow/lite/schema/schema_conversion_utils.h \
311313
tensorflow/lite/schema/schema_utils.h \
312314
tensorflow/lite/version.h
313315

tensorflow/lite/schema/BUILD

+13
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,17 @@ cc_library(
143143
],
144144
)
145145

146+
cc_library(
147+
name = "schema_conversion_utils",
148+
srcs = ["schema_conversion_utils.cc"],
149+
hdrs = ["schema_conversion_utils.h"],
150+
compatible_with = get_compatible_with_portable(),
151+
visibility = [":utils_friends"],
152+
deps = [
153+
":schema_fbs",
154+
"//tensorflow/lite/kernels/internal:compatibility",
155+
"@flatbuffers",
156+
],
157+
)
158+
146159
tflite_portable_test_suite()

0 commit comments

Comments
 (0)