Skip to content

Commit 6bb1e3a

Browse files
authored
build: update flatbuffers dependency to v23.5.26 (#2274)
Update the third_party flatbuffers library to v23.5.26, the current version in upstream TF. Synchronize the override BUILD and build_defs.bzl files with those from upstream TF at e4485c98eae. Also update the Makefile build, which downloads flatbuffers separately. Rebase the patch applied to the download. Regenerate the generated-and-checked-in schemas (see ci/sync_from_upstream_tf.sh and codegen/preprocessor/ update_schema.sh), because they are stamped with the version of the flatbuffers library, and fail a static_assert if they are built with a different version of flatbuffers than they were generated with. BUG=unsuccessful attempt to fix warning in #2183
1 parent 49ab008 commit 6bb1e3a

File tree

10 files changed

+16695
-16555
lines changed

10 files changed

+16695
-16555
lines changed

codegen/preprocessor/preprocessor_schema_generated.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
// Ensure the included flatbuffers.h is the same version as when this file was
1010
// generated, otherwise it may not be compatible.
11-
static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
12-
FLATBUFFERS_VERSION_MINOR == 0 &&
13-
FLATBUFFERS_VERSION_REVISION == 6,
11+
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
12+
FLATBUFFERS_VERSION_MINOR == 5 &&
13+
FLATBUFFERS_VERSION_REVISION == 26,
1414
"Non-compatible flatbuffers version included");
1515

1616
namespace tflm {
@@ -21,133 +21,133 @@ struct Data;
2121
struct DataBuilder;
2222
struct DataT;
2323

24-
struct DataT : public flatbuffers::NativeTable {
24+
struct DataT : public ::flatbuffers::NativeTable {
2525
typedef Data TableType;
2626
std::string input_model_path{};
2727
};
2828

29-
struct Data FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
29+
struct Data FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
3030
typedef DataT NativeTableType;
3131
typedef DataBuilder Builder;
3232
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
3333
VT_INPUT_MODEL_PATH = 4
3434
};
35-
const flatbuffers::String *input_model_path() const {
36-
return GetPointer<const flatbuffers::String *>(VT_INPUT_MODEL_PATH);
35+
const ::flatbuffers::String *input_model_path() const {
36+
return GetPointer<const ::flatbuffers::String *>(VT_INPUT_MODEL_PATH);
3737
}
38-
bool Verify(flatbuffers::Verifier &verifier) const {
38+
bool Verify(::flatbuffers::Verifier &verifier) const {
3939
return VerifyTableStart(verifier) &&
4040
VerifyOffset(verifier, VT_INPUT_MODEL_PATH) &&
4141
verifier.VerifyString(input_model_path()) &&
4242
verifier.EndTable();
4343
}
44-
DataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
45-
void UnPackTo(DataT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
46-
static flatbuffers::Offset<Data> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
44+
DataT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
45+
void UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
46+
static ::flatbuffers::Offset<Data> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
4747
};
4848

4949
struct DataBuilder {
5050
typedef Data Table;
51-
flatbuffers::FlatBufferBuilder &fbb_;
52-
flatbuffers::uoffset_t start_;
53-
void add_input_model_path(flatbuffers::Offset<flatbuffers::String> input_model_path) {
51+
::flatbuffers::FlatBufferBuilder &fbb_;
52+
::flatbuffers::uoffset_t start_;
53+
void add_input_model_path(::flatbuffers::Offset<::flatbuffers::String> input_model_path) {
5454
fbb_.AddOffset(Data::VT_INPUT_MODEL_PATH, input_model_path);
5555
}
56-
explicit DataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
56+
explicit DataBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
5757
: fbb_(_fbb) {
5858
start_ = fbb_.StartTable();
5959
}
60-
flatbuffers::Offset<Data> Finish() {
60+
::flatbuffers::Offset<Data> Finish() {
6161
const auto end = fbb_.EndTable(start_);
62-
auto o = flatbuffers::Offset<Data>(end);
62+
auto o = ::flatbuffers::Offset<Data>(end);
6363
return o;
6464
}
6565
};
6666

67-
inline flatbuffers::Offset<Data> CreateData(
68-
flatbuffers::FlatBufferBuilder &_fbb,
69-
flatbuffers::Offset<flatbuffers::String> input_model_path = 0) {
67+
inline ::flatbuffers::Offset<Data> CreateData(
68+
::flatbuffers::FlatBufferBuilder &_fbb,
69+
::flatbuffers::Offset<::flatbuffers::String> input_model_path = 0) {
7070
DataBuilder builder_(_fbb);
7171
builder_.add_input_model_path(input_model_path);
7272
return builder_.Finish();
7373
}
7474

75-
inline flatbuffers::Offset<Data> CreateDataDirect(
76-
flatbuffers::FlatBufferBuilder &_fbb,
75+
inline ::flatbuffers::Offset<Data> CreateDataDirect(
76+
::flatbuffers::FlatBufferBuilder &_fbb,
7777
const char *input_model_path = nullptr) {
7878
auto input_model_path__ = input_model_path ? _fbb.CreateString(input_model_path) : 0;
7979
return tflm::codegen::preprocessor::CreateData(
8080
_fbb,
8181
input_model_path__);
8282
}
8383

84-
flatbuffers::Offset<Data> CreateData(flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
84+
::flatbuffers::Offset<Data> CreateData(::flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
8585

86-
inline DataT *Data::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
86+
inline DataT *Data::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
8787
auto _o = std::unique_ptr<DataT>(new DataT());
8888
UnPackTo(_o.get(), _resolver);
8989
return _o.release();
9090
}
9191

92-
inline void Data::UnPackTo(DataT *_o, const flatbuffers::resolver_function_t *_resolver) const {
92+
inline void Data::UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
9393
(void)_o;
9494
(void)_resolver;
9595
{ auto _e = input_model_path(); if (_e) _o->input_model_path = _e->str(); }
9696
}
9797

98-
inline flatbuffers::Offset<Data> Data::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
98+
inline ::flatbuffers::Offset<Data> Data::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
9999
return CreateData(_fbb, _o, _rehasher);
100100
}
101101

102-
inline flatbuffers::Offset<Data> CreateData(flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
102+
inline ::flatbuffers::Offset<Data> CreateData(::flatbuffers::FlatBufferBuilder &_fbb, const DataT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
103103
(void)_rehasher;
104104
(void)_o;
105-
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DataT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
105+
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const DataT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
106106
auto _input_model_path = _o->input_model_path.empty() ? 0 : _fbb.CreateString(_o->input_model_path);
107107
return tflm::codegen::preprocessor::CreateData(
108108
_fbb,
109109
_input_model_path);
110110
}
111111

112112
inline const tflm::codegen::preprocessor::Data *GetData(const void *buf) {
113-
return flatbuffers::GetRoot<tflm::codegen::preprocessor::Data>(buf);
113+
return ::flatbuffers::GetRoot<tflm::codegen::preprocessor::Data>(buf);
114114
}
115115

116116
inline const tflm::codegen::preprocessor::Data *GetSizePrefixedData(const void *buf) {
117-
return flatbuffers::GetSizePrefixedRoot<tflm::codegen::preprocessor::Data>(buf);
117+
return ::flatbuffers::GetSizePrefixedRoot<tflm::codegen::preprocessor::Data>(buf);
118118
}
119119

120120
inline bool VerifyDataBuffer(
121-
flatbuffers::Verifier &verifier) {
121+
::flatbuffers::Verifier &verifier) {
122122
return verifier.VerifyBuffer<tflm::codegen::preprocessor::Data>(nullptr);
123123
}
124124

125125
inline bool VerifySizePrefixedDataBuffer(
126-
flatbuffers::Verifier &verifier) {
126+
::flatbuffers::Verifier &verifier) {
127127
return verifier.VerifySizePrefixedBuffer<tflm::codegen::preprocessor::Data>(nullptr);
128128
}
129129

130130
inline void FinishDataBuffer(
131-
flatbuffers::FlatBufferBuilder &fbb,
132-
flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
131+
::flatbuffers::FlatBufferBuilder &fbb,
132+
::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
133133
fbb.Finish(root);
134134
}
135135

136136
inline void FinishSizePrefixedDataBuffer(
137-
flatbuffers::FlatBufferBuilder &fbb,
138-
flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
137+
::flatbuffers::FlatBufferBuilder &fbb,
138+
::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
139139
fbb.FinishSizePrefixed(root);
140140
}
141141

142142
inline std::unique_ptr<tflm::codegen::preprocessor::DataT> UnPackData(
143143
const void *buf,
144-
const flatbuffers::resolver_function_t *res = nullptr) {
144+
const ::flatbuffers::resolver_function_t *res = nullptr) {
145145
return std::unique_ptr<tflm::codegen::preprocessor::DataT>(GetData(buf)->UnPack(res));
146146
}
147147

148148
inline std::unique_ptr<tflm::codegen::preprocessor::DataT> UnPackSizePrefixedData(
149149
const void *buf,
150-
const flatbuffers::resolver_function_t *res = nullptr) {
150+
const ::flatbuffers::resolver_function_t *res = nullptr) {
151151
return std::unique_ptr<tflm::codegen::preprocessor::DataT>(GetSizePrefixedData(buf)->UnPack(res));
152152
}
153153

codegen/preprocessor/preprocessor_schema_py_generated.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ def InputModelPath(self):
3232
return self._tab.String(o + self._tab.Pos)
3333
return None
3434

35-
def DataStart(builder): builder.StartObject(1)
36-
def Start(builder):
37-
return DataStart(builder)
38-
def DataAddInputModelPath(builder, inputModelPath): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputModelPath), 0)
39-
def AddInputModelPath(builder, inputModelPath):
40-
return DataAddInputModelPath(builder, inputModelPath)
41-
def DataEnd(builder): return builder.EndObject()
42-
def End(builder):
43-
return DataEnd(builder)
35+
def DataStart(builder):
36+
builder.StartObject(1)
37+
38+
def DataAddInputModelPath(builder, inputModelPath):
39+
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputModelPath), 0)
40+
41+
def DataEnd(builder):
42+
return builder.EndObject()
43+
44+
4445

4546
class DataT(object):
4647

@@ -54,6 +55,11 @@ def InitFromBuf(cls, buf, pos):
5455
data.Init(buf, pos)
5556
return cls.InitFromObj(data)
5657

58+
@classmethod
59+
def InitFromPackedBuf(cls, buf, pos=0):
60+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
61+
return cls.InitFromBuf(buf, pos+n)
62+
5763
@classmethod
5864
def InitFromObj(cls, data):
5965
x = DataT()
@@ -75,3 +81,5 @@ def Pack(self, builder):
7581
DataAddInputModelPath(builder, inputModelPath)
7682
data = DataEnd(builder)
7783
return data
84+
85+

tensorflow/lite/micro/tools/make/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,20 +522,31 @@ $(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/array.h \
522522
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/base.h \
523523
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/buffer.h \
524524
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/buffer_ref.h \
525+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/code_generator.h \
526+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/code_generators.h \
525527
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/default_allocator.h \
526528
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/detached_buffer.h \
529+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/file_manager.h \
527530
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flatbuffer_builder.h \
528531
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flatbuffers.h \
532+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flex_flat_util.h \
529533
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flexbuffers.h \
534+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/grpc.h \
535+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/hash.h \
536+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/idl.h \
537+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/minireflect.h \
538+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/reflection.h \
539+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/reflection_generated.h \
540+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/registry.h \
530541
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/stl_emulation.h \
531542
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/string.h \
532543
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/struct.h \
533544
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/table.h \
545+
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/util.h \
534546
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/vector.h \
535547
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/vector_downward.h \
536548
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/verifier.h \
537-
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/util.h \
538-
$(DOWNLOADS_DIR)/flatbuffers/LICENSE.txt \
549+
$(DOWNLOADS_DIR)/flatbuffers/LICENSE \
539550
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint.h \
540551
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint_neon.h \
541552
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint_sse.h \

tensorflow/lite/micro/tools/make/flatbuffers.patch

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
2-
index a5ac10d..371b6fd 100644
2+
index 5c4cae79..1a631641 100644
33
--- a/include/flatbuffers/base.h
44
+++ b/include/flatbuffers/base.h
55
@@ -1,6 +1,16 @@
@@ -20,10 +20,10 @@ index a5ac10d..371b6fd 100644
2020

2121
// If activate should be declared and included first.
2222
diff --git a/include/flatbuffers/default_allocator.h b/include/flatbuffers/default_allocator.h
23-
index 8b173af..975d938 100644
23+
index d4724122..975d9380 100644
2424
--- a/include/flatbuffers/default_allocator.h
2525
+++ b/include/flatbuffers/default_allocator.h
26-
@@ -39,26 +39,20 @@ class DefaultAllocator : public Allocator {
26+
@@ -39,24 +39,18 @@ class DefaultAllocator : public Allocator {
2727
// This is to avoid having a statically or dynamically allocated default
2828
// allocator, or having to move it between the classes that may own it.
2929
inline uint8_t *Allocate(Allocator *allocator, size_t size) {
@@ -52,15 +52,11 @@ index 8b173af..975d938 100644
5252
}
5353

5454
} // namespace flatbuffers
55-
56-
-#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
57-
\ No newline at end of file
58-
+#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
5955
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h
60-
index 89f3f30..6e6d0b3 100644
56+
index 8e8cac14..52dae316 100644
6157
--- a/include/flatbuffers/flexbuffers.h
6258
+++ b/include/flatbuffers/flexbuffers.h
63-
@@ -496,9 +496,24 @@ class Reference {
59+
@@ -495,9 +495,24 @@ class Reference {
6460
return static_cast<double>(ReadUInt64(Indirect(), byte_width_));
6561
case FBT_NULL: return 0.0;
6662
case FBT_STRING: {
@@ -86,10 +82,10 @@ index 89f3f30..6e6d0b3 100644
8682
case FBT_VECTOR: return static_cast<double>(AsVector().size());
8783
case FBT_BOOL:
8884
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
89-
index 93a39de..1cd4e8f 100644
85+
index 1ccf3517..34a75193 100644
9086
--- a/include/flatbuffers/util.h
9187
+++ b/include/flatbuffers/util.h
92-
@@ -24,6 +24,12 @@
88+
@@ -23,6 +23,12 @@
9389
#include "flatbuffers/base.h"
9490
#include "flatbuffers/stl_emulation.h"
9591

@@ -102,4 +98,3 @@ index 93a39de..1cd4e8f 100644
10298
#ifndef FLATBUFFERS_PREFER_PRINTF
10399
# include <iomanip>
104100
# include <sstream>
105-

tensorflow/lite/micro/tools/make/flatbuffers_download.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ DOWNLOADED_FLATBUFFERS_PATH=${DOWNLOADS_DIR}/flatbuffers
5454
if [ -d ${DOWNLOADED_FLATBUFFERS_PATH} ]; then
5555
echo >&2 "${DOWNLOADED_FLATBUFFERS_PATH} already exists, skipping the download."
5656
else
57-
ZIP_PREFIX="a66de58af9565586832c276fbb4251fc416bf07f"
57+
ZIP_PREFIX="v23.5.26"
5858
FLATBUFFERS_URL="https://github.com/google/flatbuffers/archive/${ZIP_PREFIX}.zip"
59-
FLATBUFFERS_MD5="51a7a96747e1c33eb4aac6d52513a02f"
59+
FLATBUFFERS_MD5="e87e8acd8e2d53653387ad78720316e2"
6060

6161
TEMPDIR="$(mktemp -d)"
6262
TEMPFILE="${TEMPDIR}/${ZIP_PREFIX}.zip"
6363
wget ${FLATBUFFERS_URL} -O "$TEMPFILE" >&2
6464
check_md5 "${TEMPFILE}" ${FLATBUFFERS_MD5}
6565

6666
unzip -qo "$TEMPFILE" -d "${TEMPDIR}" >&2
67-
mv "${TEMPDIR}/flatbuffers-${ZIP_PREFIX}" ${DOWNLOADED_FLATBUFFERS_PATH}
67+
mv "${TEMPDIR}/flatbuffers-${ZIP_PREFIX#v}" ${DOWNLOADED_FLATBUFFERS_PATH}
6868
rm -rf "${TEMPDIR}"
6969

7070
pushd ${DOWNLOADED_FLATBUFFERS_PATH} > /dev/null

0 commit comments

Comments
 (0)