Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update flatbuffers dependency to v23.5.26 #2274

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions codegen/preprocessor/preprocessor_schema_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

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

namespace tflm {
Expand All @@ -21,133 +21,133 @@ struct Data;
struct DataBuilder;
struct DataT;

struct DataT : public flatbuffers::NativeTable {
struct DataT : public ::flatbuffers::NativeTable {
typedef Data TableType;
std::string input_model_path{};
};

struct Data FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
struct Data FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef DataT NativeTableType;
typedef DataBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_INPUT_MODEL_PATH = 4
};
const flatbuffers::String *input_model_path() const {
return GetPointer<const flatbuffers::String *>(VT_INPUT_MODEL_PATH);
const ::flatbuffers::String *input_model_path() const {
return GetPointer<const ::flatbuffers::String *>(VT_INPUT_MODEL_PATH);
}
bool Verify(flatbuffers::Verifier &verifier) const {
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyOffset(verifier, VT_INPUT_MODEL_PATH) &&
verifier.VerifyString(input_model_path()) &&
verifier.EndTable();
}
DataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
void UnPackTo(DataT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
static flatbuffers::Offset<Data> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
DataT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
void UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
static ::flatbuffers::Offset<Data> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const DataT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
};

struct DataBuilder {
typedef Data Table;
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_input_model_path(flatbuffers::Offset<flatbuffers::String> input_model_path) {
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_input_model_path(::flatbuffers::Offset<::flatbuffers::String> input_model_path) {
fbb_.AddOffset(Data::VT_INPUT_MODEL_PATH, input_model_path);
}
explicit DataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
explicit DataBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
flatbuffers::Offset<Data> Finish() {
::flatbuffers::Offset<Data> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = flatbuffers::Offset<Data>(end);
auto o = ::flatbuffers::Offset<Data>(end);
return o;
}
};

inline flatbuffers::Offset<Data> CreateData(
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::String> input_model_path = 0) {
inline ::flatbuffers::Offset<Data> CreateData(
::flatbuffers::FlatBufferBuilder &_fbb,
::flatbuffers::Offset<::flatbuffers::String> input_model_path = 0) {
DataBuilder builder_(_fbb);
builder_.add_input_model_path(input_model_path);
return builder_.Finish();
}

inline flatbuffers::Offset<Data> CreateDataDirect(
flatbuffers::FlatBufferBuilder &_fbb,
inline ::flatbuffers::Offset<Data> CreateDataDirect(
::flatbuffers::FlatBufferBuilder &_fbb,
const char *input_model_path = nullptr) {
auto input_model_path__ = input_model_path ? _fbb.CreateString(input_model_path) : 0;
return tflm::codegen::preprocessor::CreateData(
_fbb,
input_model_path__);
}

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

inline DataT *Data::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
inline DataT *Data::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
auto _o = std::unique_ptr<DataT>(new DataT());
UnPackTo(_o.get(), _resolver);
return _o.release();
}

inline void Data::UnPackTo(DataT *_o, const flatbuffers::resolver_function_t *_resolver) const {
inline void Data::UnPackTo(DataT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
(void)_o;
(void)_resolver;
{ auto _e = input_model_path(); if (_e) _o->input_model_path = _e->str(); }
}

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

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

inline const tflm::codegen::preprocessor::Data *GetData(const void *buf) {
return flatbuffers::GetRoot<tflm::codegen::preprocessor::Data>(buf);
return ::flatbuffers::GetRoot<tflm::codegen::preprocessor::Data>(buf);
}

inline const tflm::codegen::preprocessor::Data *GetSizePrefixedData(const void *buf) {
return flatbuffers::GetSizePrefixedRoot<tflm::codegen::preprocessor::Data>(buf);
return ::flatbuffers::GetSizePrefixedRoot<tflm::codegen::preprocessor::Data>(buf);
}

inline bool VerifyDataBuffer(
flatbuffers::Verifier &verifier) {
::flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<tflm::codegen::preprocessor::Data>(nullptr);
}

inline bool VerifySizePrefixedDataBuffer(
flatbuffers::Verifier &verifier) {
::flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<tflm::codegen::preprocessor::Data>(nullptr);
}

inline void FinishDataBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
fbb.Finish(root);
}

inline void FinishSizePrefixedDataBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<tflm::codegen::preprocessor::Data> root) {
fbb.FinishSizePrefixed(root);
}

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

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

Expand Down
26 changes: 17 additions & 9 deletions codegen/preprocessor/preprocessor_schema_py_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ def InputModelPath(self):
return self._tab.String(o + self._tab.Pos)
return None

def DataStart(builder): builder.StartObject(1)
def Start(builder):
return DataStart(builder)
def DataAddInputModelPath(builder, inputModelPath): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputModelPath), 0)
def AddInputModelPath(builder, inputModelPath):
return DataAddInputModelPath(builder, inputModelPath)
def DataEnd(builder): return builder.EndObject()
def End(builder):
return DataEnd(builder)
def DataStart(builder):
builder.StartObject(1)

def DataAddInputModelPath(builder, inputModelPath):
builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(inputModelPath), 0)

def DataEnd(builder):
return builder.EndObject()



class DataT(object):

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

@classmethod
def InitFromPackedBuf(cls, buf, pos=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
return cls.InitFromBuf(buf, pos+n)

@classmethod
def InitFromObj(cls, data):
x = DataT()
Expand All @@ -75,3 +81,5 @@ def Pack(self, builder):
DataAddInputModelPath(builder, inputModelPath)
data = DataEnd(builder)
return data


15 changes: 13 additions & 2 deletions tensorflow/lite/micro/tools/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -522,20 +522,31 @@ $(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/array.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/base.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/buffer.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/buffer_ref.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/code_generator.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/code_generators.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/default_allocator.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/detached_buffer.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/file_manager.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flatbuffer_builder.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flatbuffers.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flex_flat_util.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/flexbuffers.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/grpc.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/hash.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/idl.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/minireflect.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/reflection.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/reflection_generated.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/registry.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/stl_emulation.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/string.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/struct.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/table.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/util.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/vector.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/vector_downward.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/verifier.h \
$(DOWNLOADS_DIR)/flatbuffers/include/flatbuffers/util.h \
$(DOWNLOADS_DIR)/flatbuffers/LICENSE.txt \
$(DOWNLOADS_DIR)/flatbuffers/LICENSE \
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint.h \
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint_neon.h \
$(DOWNLOADS_DIR)/gemmlowp/fixedpoint/fixedpoint_sse.h \
Expand Down
19 changes: 7 additions & 12 deletions tensorflow/lite/micro/tools/make/flatbuffers.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
index a5ac10d..371b6fd 100644
index 5c4cae79..1a631641 100644
--- a/include/flatbuffers/base.h
+++ b/include/flatbuffers/base.h
@@ -1,6 +1,16 @@
Expand All @@ -20,10 +20,10 @@ index a5ac10d..371b6fd 100644

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

} // namespace flatbuffers

-#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
\ No newline at end of file
+#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h
index 89f3f30..6e6d0b3 100644
index 8e8cac14..52dae316 100644
--- a/include/flatbuffers/flexbuffers.h
+++ b/include/flatbuffers/flexbuffers.h
@@ -496,9 +496,24 @@ class Reference {
@@ -495,9 +495,24 @@ class Reference {
return static_cast<double>(ReadUInt64(Indirect(), byte_width_));
case FBT_NULL: return 0.0;
case FBT_STRING: {
Expand All @@ -86,10 +82,10 @@ index 89f3f30..6e6d0b3 100644
case FBT_VECTOR: return static_cast<double>(AsVector().size());
case FBT_BOOL:
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 93a39de..1cd4e8f 100644
index 1ccf3517..34a75193 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -24,6 +24,12 @@
@@ -23,6 +23,12 @@
#include "flatbuffers/base.h"
#include "flatbuffers/stl_emulation.h"

Expand All @@ -102,4 +98,3 @@ index 93a39de..1cd4e8f 100644
#ifndef FLATBUFFERS_PREFER_PRINTF
# include <iomanip>
# include <sstream>

6 changes: 3 additions & 3 deletions tensorflow/lite/micro/tools/make/flatbuffers_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ DOWNLOADED_FLATBUFFERS_PATH=${DOWNLOADS_DIR}/flatbuffers
if [ -d ${DOWNLOADED_FLATBUFFERS_PATH} ]; then
echo >&2 "${DOWNLOADED_FLATBUFFERS_PATH} already exists, skipping the download."
else
ZIP_PREFIX="a66de58af9565586832c276fbb4251fc416bf07f"
ZIP_PREFIX="v23.5.26"
FLATBUFFERS_URL="https://github.com/google/flatbuffers/archive/${ZIP_PREFIX}.zip"
FLATBUFFERS_MD5="51a7a96747e1c33eb4aac6d52513a02f"
FLATBUFFERS_MD5="e87e8acd8e2d53653387ad78720316e2"

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

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

pushd ${DOWNLOADED_FLATBUFFERS_PATH} > /dev/null
Expand Down
Loading