mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
Merge pull request #20683 from FlapKap/update-tfmicro
pkg/tflite-micro: Update tflite-micro to latest version. requires update of pkg/flatbuffers as well.
This commit is contained in:
commit
2f3c262fdd
2
dist/tools/flatc/Makefile
vendored
2
dist/tools/flatc/Makefile
vendored
@ -1,6 +1,6 @@
|
||||
PKG_NAME=flatbuffers
|
||||
PKG_URL=https://github.com/google/flatbuffers
|
||||
PKG_VERSION=9e7e8cbe9f675123dd41b7c62868acad39188cae
|
||||
PKG_VERSION=0100f6a5779831fa7a651e4b67ef389a8752bd9b
|
||||
PKG_LICENSE=Apache2.0
|
||||
|
||||
# manually set some RIOT env vars, so this Makefile can be called stand-alone
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
From e77a8fe4b722ec79bf31b1e855dbf938e900fa60 Mon Sep 17 00:00:00 2001
|
||||
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
Date: Wed, 9 Nov 2022 22:29:07 +0100
|
||||
Subject: [PATCH] CMakeLists.txt: fix compilation on musl
|
||||
|
||||
For some reason musl does provide `strtof_l()`, but none of the others.
|
||||
It shouldn't even provide `strtof_l()`, as musl has zero locale
|
||||
support.
|
||||
|
||||
This changes the check for a libc with locale support to check for
|
||||
`strtoull_l()` rather than for `strtof_l()`, which also works for
|
||||
musl.
|
||||
---
|
||||
CMakeLists.txt | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 119855a..7ad7636 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -45,9 +45,9 @@ endif()
|
||||
# Auto-detect locale-narrow 'strtod_l' function.
|
||||
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
if(MSVC)
|
||||
- check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
+ check_cxx_symbol_exists(_strtoull_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
else()
|
||||
- check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
+ check_cxx_symbol_exists(strtoull_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
endif()
|
||||
endif()
|
||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||
--
|
||||
2.38.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
PKG_NAME=flatbuffers
|
||||
PKG_URL=https://github.com/google/flatbuffers
|
||||
# v2.0.0
|
||||
PKG_VERSION=a9a295fecf3fbd5a4f571f53b01f63202a3e2113
|
||||
# v23.5.26
|
||||
PKG_VERSION=0100f6a5779831fa7a651e4b67ef389a8752bd9b
|
||||
PKG_LICENSE=Apache2.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
@ -1,39 +1,132 @@
|
||||
From 6ede404cf13233bd75f6af4fc487649c7bfd27c7 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
Date: Thu, 7 Apr 2022 11:14:49 +0200
|
||||
From 2ce377f5a799abce0b6a3c8539857b702efaa5b3 Mon Sep 17 00:00:00 2001
|
||||
From: Kasper Hjort Berthelsen <khjo@itu.dk>
|
||||
Date: Wed, 22 May 2024 13:51:37 +0200
|
||||
Subject: [PATCH 1/1] Silence Wcast-align in public headers
|
||||
|
||||
---
|
||||
include/flatbuffers/flatbuffers.h | 42 +++++++++++++++++++++++++++++++
|
||||
1 file changed, 42 insertions(+)
|
||||
include/flatbuffers/buffer.h | 9 +++++++++
|
||||
include/flatbuffers/flatbuffer_builder.h | 12 ++++++++++++
|
||||
include/flatbuffers/table.h | 6 ++++++
|
||||
include/flatbuffers/vector_downward.h | 6 ++++++
|
||||
4 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
|
||||
index ee34d54e..52cad4c6 100644
|
||||
--- a/include/flatbuffers/flatbuffers.h
|
||||
+++ b/include/flatbuffers/flatbuffers.h
|
||||
@@ -107,7 +107,10 @@ template<typename T> struct IndirectHelper {
|
||||
typedef T mutable_return_type;
|
||||
diff --git a/include/flatbuffers/buffer.h b/include/flatbuffers/buffer.h
|
||||
index 94d4f790..f496b5a5 100644
|
||||
--- a/include/flatbuffers/buffer.h
|
||||
+++ b/include/flatbuffers/buffer.h
|
||||
@@ -96,12 +96,18 @@ template<typename T> struct IndirectHelper {
|
||||
static const size_t element_stride = sizeof(T);
|
||||
static return_type Read(const uint8_t *p, uoffset_t i) {
|
||||
|
||||
static return_type Read(const uint8_t *p, const size_t i) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return EndianScalar((reinterpret_cast<const T *>(p))[i]);
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
};
|
||||
template<typename T> struct IndirectHelper<Offset<T>> {
|
||||
@@ -116,7 +119,10 @@ template<typename T> struct IndirectHelper<Offset<T>> {
|
||||
static const size_t element_stride = sizeof(uoffset_t);
|
||||
static return_type Read(const uint8_t *p, uoffset_t i) {
|
||||
p += i * sizeof(uoffset_t);
|
||||
static mutable_return_type Read(uint8_t *p, const size_t i) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p));
|
||||
return reinterpret_cast<mutable_return_type>(
|
||||
Read(const_cast<const uint8_t *>(p), i));
|
||||
}
|
||||
+#pragma GCC diagnostic pop
|
||||
};
|
||||
|
||||
// For vector of Offsets.
|
||||
@@ -119,9 +125,12 @@ struct IndirectHelper<OffsetT<T>> {
|
||||
|
||||
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
|
||||
// then determine the relative location from the offset location.
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return reinterpret_cast<return_type>(
|
||||
offset_location + ReadScalar<offset_type>(offset_location));
|
||||
}
|
||||
+#pragma GCC diagnostic pop
|
||||
static mutable_return_type Read(uint8_t *const p, const offset_type i) {
|
||||
// Offsets are relative to themselves, so first update the pointer to
|
||||
// point to the offset location.
|
||||
diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h
|
||||
index 9a2d6254..4ea23b88 100644
|
||||
--- a/include/flatbuffers/flatbuffer_builder.h
|
||||
+++ b/include/flatbuffers/flatbuffer_builder.h
|
||||
@@ -54,7 +54,10 @@ const T *data(const std::vector<T, Alloc> &v) {
|
||||
// Eventually the returned pointer gets passed down to memcpy, so
|
||||
// we need it to be non-null to avoid undefined behavior.
|
||||
static uint8_t t;
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
T *data(std::vector<T, Alloc> &v) {
|
||||
@@ -440,7 +443,10 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
|
||||
// Write the offsets into the table
|
||||
for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc);
|
||||
it < buf_.scratch_end(); it += sizeof(FieldLoc)) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto field_location = reinterpret_cast<FieldLoc *>(it);
|
||||
+#pragma GCC diagnostic pop
|
||||
const voffset_t pos =
|
||||
static_cast<voffset_t>(vtable_offset_loc - field_location->off);
|
||||
// If this asserts, it means you've set a field twice.
|
||||
@@ -449,7 +455,10 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
|
||||
WriteScalar<voffset_t>(buf_.data() + field_location->id, pos);
|
||||
}
|
||||
ClearOffsets();
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto vt1 = reinterpret_cast<voffset_t *>(buf_.data());
|
||||
+#pragma GCC diagnostic pop
|
||||
auto vt1_size = ReadScalar<voffset_t>(vt1);
|
||||
auto vt_use = GetSizeRelative32BitRegion();
|
||||
// See if we already have generated a vtable with this exact same
|
||||
@@ -457,8 +466,11 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
|
||||
if (dedup_vtables_) {
|
||||
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
|
||||
it += sizeof(uoffset_t)) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it);
|
||||
auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr));
|
||||
+#pragma GCC diagnostic pop
|
||||
auto vt2_size = ReadScalar<voffset_t>(vt2);
|
||||
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
|
||||
vt_use = *vt_offset_ptr;
|
||||
diff --git a/include/flatbuffers/table.h b/include/flatbuffers/table.h
|
||||
index e92d8ae8..c2400a3b 100644
|
||||
--- a/include/flatbuffers/table.h
|
||||
+++ b/include/flatbuffers/table.h
|
||||
@@ -51,8 +51,11 @@ class Table {
|
||||
P GetPointer(voffset_t field) {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
auto p = data_ + field_offset;
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
|
||||
: nullptr;
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
};
|
||||
template<typename T> struct IndirectHelper<const T *> {
|
||||
@@ -1034,12 +1040,18 @@ class vector_downward {
|
||||
template<typename P, typename OffsetSize = uoffset_t>
|
||||
P GetPointer(voffset_t field) const {
|
||||
@@ -70,7 +73,10 @@ class Table {
|
||||
template<typename P> P GetStruct(voffset_t field) const {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
auto p = const_cast<uint8_t *>(data_ + field_offset);
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return field_offset ? reinterpret_cast<P>(p) : nullptr;
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
template<typename Raw, typename Face>
|
||||
diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h
|
||||
index 2b5a92cf..dd869444 100644
|
||||
--- a/include/flatbuffers/vector_downward.h
|
||||
+++ b/include/flatbuffers/vector_downward.h
|
||||
@@ -199,12 +199,18 @@ template<typename SizeT = uoffset_t> class vector_downward {
|
||||
// Specialized version of push() that avoids memcpy call for small data.
|
||||
template<typename T> void push_small(const T &little_endian_t) {
|
||||
make_space(sizeof(T));
|
||||
@ -52,117 +145,6 @@ index ee34d54e..52cad4c6 100644
|
||||
scratch_ += sizeof(T);
|
||||
}
|
||||
|
||||
@@ -1121,13 +1133,19 @@ const T *data(const std::vector<T, Alloc> &v) {
|
||||
// Eventually the returned pointer gets passed down to memcpy, so
|
||||
// we need it to be non-null to avoid undefined behavior.
|
||||
static uint8_t t;
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) {
|
||||
// Eventually the returned pointer gets passed down to memcpy, so
|
||||
// we need it to be non-null to avoid undefined behavior.
|
||||
static uint8_t t;
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return v.empty() ? reinterpret_cast<T *>(&t) : &v.front();
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
@@ -1465,7 +1483,10 @@ class FlatBufferBuilder {
|
||||
// Write the offsets into the table
|
||||
for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc);
|
||||
it < buf_.scratch_end(); it += sizeof(FieldLoc)) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto field_location = reinterpret_cast<FieldLoc *>(it);
|
||||
+#pragma GCC diagnostic pop
|
||||
auto pos = static_cast<voffset_t>(vtableoffsetloc - field_location->off);
|
||||
// If this asserts, it means you've set a field twice.
|
||||
FLATBUFFERS_ASSERT(
|
||||
@@ -1473,7 +1494,10 @@ class FlatBufferBuilder {
|
||||
WriteScalar<voffset_t>(buf_.data() + field_location->id, pos);
|
||||
}
|
||||
ClearOffsets();
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto vt1 = reinterpret_cast<voffset_t *>(buf_.data());
|
||||
+#pragma GCC diagnostic pop
|
||||
auto vt1_size = ReadScalar<voffset_t>(vt1);
|
||||
auto vt_use = GetSize();
|
||||
// See if we already have generated a vtable with this exact same
|
||||
@@ -1481,8 +1505,11 @@ class FlatBufferBuilder {
|
||||
if (dedup_vtables_) {
|
||||
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
|
||||
it += sizeof(uoffset_t)) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it);
|
||||
auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr));
|
||||
+#pragma GCC diagnostic pop
|
||||
auto vt2_size = ReadScalar<voffset_t>(vt2);
|
||||
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
|
||||
vt_use = *vt_offset_ptr;
|
||||
@@ -2184,8 +2211,11 @@ class FlatBufferBuilder {
|
||||
struct StringOffsetCompare {
|
||||
StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {}
|
||||
bool operator()(const Offset<String> &a, const Offset<String> &b) const {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto stra = reinterpret_cast<const String *>(buf_->data_at(a.o));
|
||||
auto strb = reinterpret_cast<const String *>(buf_->data_at(b.o));
|
||||
+#pragma GCC diagnostic pop
|
||||
return StringLessThan(stra->data(), stra->size(), strb->data(),
|
||||
strb->size());
|
||||
}
|
||||
@@ -2578,8 +2608,11 @@ class Table {
|
||||
template<typename P> P GetPointer(voffset_t field) {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
auto p = data_ + field_offset;
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return field_offset ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p))
|
||||
: nullptr;
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
template<typename P> P GetPointer(voffset_t field) const {
|
||||
return const_cast<Table *>(this)->GetPointer<P>(field);
|
||||
@@ -2588,7 +2621,10 @@ class Table {
|
||||
template<typename P> P GetStruct(voffset_t field) const {
|
||||
auto field_offset = GetOptionalFieldOffset(field);
|
||||
auto p = const_cast<uint8_t *>(data_ + field_offset);
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
return field_offset ? reinterpret_cast<P>(p) : nullptr;
|
||||
+#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
template<typename Raw, typename Face>
|
||||
@@ -2691,7 +2727,10 @@ inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>(
|
||||
|
||||
template<typename T>
|
||||
void FlatBufferBuilder::Required(Offset<T> table, voffset_t field) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto table_ptr = reinterpret_cast<const Table *>(buf_.data_at(table.o));
|
||||
+#pragma GCC diagnostic pop
|
||||
bool ok = table_ptr->GetOptionalFieldOffset(field) != 0;
|
||||
// If this fails, the caller will show what field needs to be set.
|
||||
FLATBUFFERS_ASSERT(ok);
|
||||
@@ -2703,7 +2742,10 @@ void FlatBufferBuilder::Required(Offset<T> table, voffset_t field) {
|
||||
/// This may be useful if you want to pass on a root and have the recipient
|
||||
/// delete the buffer afterwards.
|
||||
inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
auto table = reinterpret_cast<const Table *>(root);
|
||||
+#pragma GCC diagnostic pop
|
||||
auto vtable = table->GetVTable();
|
||||
// Either the vtable is before the root or after the root.
|
||||
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root));
|
||||
--
|
||||
2.32.0
|
||||
2.34.1
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
PKG_NAME=tflite-micro
|
||||
PKG_URL=https://github.com/tensorflow/tflite-micro
|
||||
# sync from 2022.04.07
|
||||
PKG_VERSION=1501b574b74fd7877aba30aa9d8b667f41b139c3
|
||||
# sync from 2024.05.21
|
||||
PKG_VERSION=8e22946b3faa51564df5dd9194f7540b2694892c
|
||||
PKG_LICENSE=Apache 2.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
@ -14,23 +14,29 @@ CFLAGS += -Wno-unused-parameter
|
||||
TFLITE_MODULES := \
|
||||
tflite-c \
|
||||
tflite-core-api \
|
||||
tflite-core-c \
|
||||
tflite-kernels \
|
||||
tflite-kernels-internal \
|
||||
tflite-kernels-internal-reference \
|
||||
tflite-micro \
|
||||
tflite-micro-arena_allocator \
|
||||
tflite-micro-kernels \
|
||||
tflite-micro-memory-planner \
|
||||
tflite-micro-tflite_bridge \
|
||||
tflite-schema \
|
||||
#
|
||||
|
||||
DIR_tflite-c := tensorflow/lite/c
|
||||
DIR_tflite-core-api := tensorflow/lite/core/api
|
||||
DIR_tflite-core-c := tensorflow/lite/core/c
|
||||
DIR_tflite-kernels := tensorflow/lite/kernels
|
||||
DIR_tflite-kernels-internal := tensorflow/lite/kernels/internal
|
||||
DIR_tflite-kernels-internal-reference := tensorflow/lite/kernels/internal/reference
|
||||
DIR_tflite-micro := tensorflow/lite/micro
|
||||
DIR_tflite-micro-arena_allocator := tensorflow/lite/micro/arena_allocator
|
||||
DIR_tflite-micro-kernels := tensorflow/lite/micro/kernels
|
||||
DIR_tflite-micro-memory-planner := tensorflow/lite/micro/memory_planner
|
||||
DIR_tflite-micro-tflite_bridge := tensorflow/lite/micro/tflite_bridge
|
||||
DIR_tflite-schema := tensorflow/lite/schema
|
||||
|
||||
TFLITE_MODULES_USED := $(filter $(TFLITE_MODULES),$(USEMODULE))
|
||||
@ -40,5 +46,11 @@ all: $(TFLITE_MODULES_USED)
|
||||
|
||||
.PHONY: tflite-%
|
||||
|
||||
tflite-%:
|
||||
$(PKG_SOURCE_DIR)/tensorflow/lite/schema/schema_generated.h: $(PKG_SOURCE_DIR)/tensorflow/lite/schema/schema.fbs $(FLATC)
|
||||
$(FLATC) --cpp -o "$(dir $@)" "$<"
|
||||
|
||||
tflite-%: $(PKG_SOURCE_DIR)/tensorflow/lite/schema/schema_generated.h
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/$(DIR_$@) -f $(CURDIR)/$@.mk
|
||||
|
||||
$(FLATC):
|
||||
$(Q)make -C "$(dir $@)"
|
||||
|
||||
@ -6,12 +6,15 @@ USEPKG += ruy
|
||||
|
||||
USEMODULE += tflite-c
|
||||
USEMODULE += tflite-core-api
|
||||
USEMODULE += tflite-core-c
|
||||
USEMODULE += tflite-kernels
|
||||
USEMODULE += tflite-kernels-internal
|
||||
USEMODULE += tflite-kernels-internal-reference
|
||||
USEMODULE += tflite-micro
|
||||
USEMODULE += tflite-micro-arena_allocator
|
||||
USEMODULE += tflite-micro-kernels
|
||||
USEMODULE += tflite-micro-memory-planner
|
||||
USEMODULE += tflite-micro-tflite_bridge
|
||||
USEMODULE += tflite-schema
|
||||
|
||||
# This package doesn't work on riscv
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
From 4e9723bbedf1317dec204397c6777f90ff76646d Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
Date: Thu, 7 Apr 2022 17:07:58 +0200
|
||||
Subject: [PATCH 1/1] fix build with private descriptor
|
||||
|
||||
---
|
||||
tensorflow/lite/micro/memory_planner/greedy_memory_planner.h | 2 --
|
||||
tensorflow/lite/micro/micro_error_reporter.h | 3 ---
|
||||
2 files changed, 5 deletions(-)
|
||||
|
||||
diff --git a/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h b/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
index a34f3c5..b8269be 100644
|
||||
--- a/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
+++ b/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
@@ -158,8 +158,6 @@ class GreedyMemoryPlanner : public MicroMemoryPlanner {
|
||||
|
||||
// Whether buffers have been added since the last plan was calculated.
|
||||
bool need_to_calculate_offsets_;
|
||||
-
|
||||
- TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
} // namespace tflite
|
||||
diff --git a/tensorflow/lite/micro/micro_error_reporter.h b/tensorflow/lite/micro/micro_error_reporter.h
|
||||
index 0e3b0c3..18a0d89 100644
|
||||
--- a/tensorflow/lite/micro/micro_error_reporter.h
|
||||
+++ b/tensorflow/lite/micro/micro_error_reporter.h
|
||||
@@ -46,9 +46,6 @@ class MicroErrorReporter : public ErrorReporter {
|
||||
public:
|
||||
~MicroErrorReporter() override {}
|
||||
int Report(const char* format, va_list args) override;
|
||||
-
|
||||
- private:
|
||||
- TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
} // namespace tflite
|
||||
--
|
||||
2.32.0
|
||||
|
||||
91
pkg/tflite-micro/patches/0001-fix-private-descriptor.patch
Normal file
91
pkg/tflite-micro/patches/0001-fix-private-descriptor.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From 8eef2021de2c2051c54cc1d9670f784485c65f13 Mon Sep 17 00:00:00 2001
|
||||
From: Kasper Hjort Berthelsen <khjo@itu.dk>
|
||||
Date: Tue, 21 May 2024 23:17:43 +0200
|
||||
Subject: [PATCH 1/1] fix private descriptor
|
||||
|
||||
---
|
||||
tensorflow/lite/micro/memory_planner/greedy_memory_planner.h | 4 ++--
|
||||
tensorflow/lite/micro/memory_planner/linear_memory_planner.h | 4 ++--
|
||||
tensorflow/lite/micro/micro_allocator.h | 4 ++--
|
||||
tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h | 1 -
|
||||
4 files changed, 6 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h b/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
index b2cdb617..77b9a1cc 100644
|
||||
--- a/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
+++ b/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h
|
||||
@@ -112,6 +112,8 @@ class GreedyMemoryPlanner : public MicroMemoryPlanner {
|
||||
// that aren't being used during a phase of invocation are overwritten.
|
||||
bool preserves_all_tensors() const override { return false; }
|
||||
|
||||
+ TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
+
|
||||
private:
|
||||
// Whether a buffer is active in a given time range.
|
||||
bool DoesEntryOverlapInTime(const ListEntry* entry, const int first_time_used,
|
||||
@@ -161,8 +163,6 @@ class GreedyMemoryPlanner : public MicroMemoryPlanner {
|
||||
|
||||
// Whether buffers have been added since the last plan was calculated.
|
||||
bool need_to_calculate_offsets_;
|
||||
-
|
||||
- TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
} // namespace tflite
|
||||
diff --git a/tensorflow/lite/micro/memory_planner/linear_memory_planner.h b/tensorflow/lite/micro/memory_planner/linear_memory_planner.h
|
||||
index 9850569f..4fbdf54e 100644
|
||||
--- a/tensorflow/lite/micro/memory_planner/linear_memory_planner.h
|
||||
+++ b/tensorflow/lite/micro/memory_planner/linear_memory_planner.h
|
||||
@@ -39,13 +39,13 @@ class LinearMemoryPlanner : public MicroMemoryPlanner {
|
||||
// invocation.
|
||||
bool preserves_all_tensors() const override { return true; }
|
||||
|
||||
+ TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
+
|
||||
private:
|
||||
static constexpr int kMaxBufferCount = 1024;
|
||||
size_t buffer_offsets_[kMaxBufferCount];
|
||||
int current_buffer_count_;
|
||||
size_t next_free_offset_;
|
||||
-
|
||||
- TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
} // namespace tflite
|
||||
diff --git a/tensorflow/lite/micro/micro_allocator.h b/tensorflow/lite/micro/micro_allocator.h
|
||||
index 4eff167d..b7895127 100644
|
||||
--- a/tensorflow/lite/micro/micro_allocator.h
|
||||
+++ b/tensorflow/lite/micro/micro_allocator.h
|
||||
@@ -291,6 +291,8 @@ class MicroAllocator {
|
||||
int subgraph_idx,
|
||||
bool allocate_temp);
|
||||
|
||||
+ TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
+
|
||||
private:
|
||||
// Commits a memory plan for all non-persistent buffer allocations in the
|
||||
// 'head' section of the memory arena. The eval_tensors pointer is the list of
|
||||
@@ -339,8 +341,6 @@ class MicroAllocator {
|
||||
// Holds the byte length of the memory plan with the largest head usage. Used
|
||||
// to ensure that multi-tenant allocations can share the head for buffers.
|
||||
size_t max_head_buffer_usage_ = 0;
|
||||
-
|
||||
- TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
} // namespace tflite
|
||||
diff --git a/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h b/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h
|
||||
index d3702f46..186a226e 100644
|
||||
--- a/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h
|
||||
+++ b/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h
|
||||
@@ -28,7 +28,6 @@ class MicroErrorReporter : public ErrorReporter {
|
||||
~MicroErrorReporter() override {}
|
||||
int Report(const char* format, va_list args) override;
|
||||
|
||||
- private:
|
||||
TF_LITE_REMOVE_VIRTUAL_DELETE
|
||||
};
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
From 027ec148ae13362c00fb9f539f359a9cd8c70af4 Mon Sep 17 00:00:00 2001
|
||||
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
Date: Fri, 11 Nov 2022 08:57:01 +0100
|
||||
Subject: [PATCH] Compare names without over-reading in
|
||||
micro_allocation_info.cc
|
||||
|
||||
This fixes:
|
||||
|
||||
/home/maribu/Repos/software/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_allocation_info.cc: In member function 'TfLiteStatus tflite::AllocationInfoBuilder::GetOfflinePlannedOffsets(const int32_t**)':
|
||||
/home/maribu/Repos/software/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_allocation_info.cc:294:18: error: 'int strncmp(const char*, const char*, size_t)' specified bound 23 exceeds source size 0 [-Werror=stringop-overread]
|
||||
294 | if (strncmp(metadata->name()->c_str(), kOfflineMemAllocMetadata,
|
||||
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
295 | strlen(kOfflineMemAllocMetadata)) == 0) {
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
---
|
||||
tensorflow/lite/micro/micro_allocation_info.cc | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tensorflow/lite/micro/micro_allocation_info.cc b/tensorflow/lite/micro/micro_allocation_info.cc
|
||||
index ab313e6..1e61135 100644
|
||||
--- a/tensorflow/lite/micro/micro_allocation_info.cc
|
||||
+++ b/tensorflow/lite/micro/micro_allocation_info.cc
|
||||
@@ -291,8 +291,10 @@ TfLiteStatus AllocationInfoBuilder::GetOfflinePlannedOffsets(
|
||||
if (model_->metadata()) {
|
||||
for (size_t i = 0; i < model_->metadata()->size(); ++i) {
|
||||
auto metadata = model_->metadata()->Get(i);
|
||||
- if (strncmp(metadata->name()->c_str(), kOfflineMemAllocMetadata,
|
||||
- strlen(kOfflineMemAllocMetadata)) == 0) {
|
||||
+ const size_t len_b = sizeof(kOfflineMemAllocMetadata) - 1;
|
||||
+ size_t len_a = metadata->name()->size();
|
||||
+ if ((len_a == len_b) &&
|
||||
+ !memcmp(kOfflineMemAllocMetadata, metadata->name()->c_str(), len_b)) {
|
||||
const flatbuffers::Vector<flatbuffers::Offset<Buffer>>* buffers =
|
||||
model_->buffers();
|
||||
auto* buffer = (*buffers)[metadata->buffer()];
|
||||
--
|
||||
2.38.1
|
||||
|
||||
5
pkg/tflite-micro/tflite-core-c.mk
Normal file
5
pkg/tflite-micro/tflite-core-c.mk
Normal file
@ -0,0 +1,5 @@
|
||||
MODULE = tflite-core-c
|
||||
|
||||
SRCXXEXT = cc
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
6
pkg/tflite-micro/tflite-micro-arena_allocator.mk
Normal file
6
pkg/tflite-micro/tflite-micro-arena_allocator.mk
Normal file
@ -0,0 +1,6 @@
|
||||
MODULE = tflite-micro-arena_allocator
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
5
pkg/tflite-micro/tflite-micro-tflite_bridge.mk
Normal file
5
pkg/tflite-micro/tflite-micro-tflite_bridge.mk
Normal file
@ -0,0 +1,5 @@
|
||||
MODULE = tflite-micro-tflite_bridge
|
||||
|
||||
SRCXXEXT = cc
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -1,109 +1,29 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
airfy-beacon \
|
||||
arduino-mkr1000 \
|
||||
arduino-mkrfox1200 \
|
||||
arduino-mkrwan1300 \
|
||||
arduino-mkrzero \
|
||||
arduino-nano-33-iot \
|
||||
arduino-zero \
|
||||
b-l072z-lrwan1 \
|
||||
bastwan \
|
||||
blackpill-stm32f103c8 \
|
||||
blackpill-stm32f103cb \
|
||||
bluepill-stm32f030c8 \
|
||||
bluepill-stm32f103c8 \
|
||||
bluepill-stm32f103cb \
|
||||
calliope-mini \
|
||||
cc1350-launchpad \
|
||||
cc2650-launchpad \
|
||||
cc2650stk \
|
||||
e104-bt5010a-tb \
|
||||
e104-bt5011a-tb \
|
||||
e180-zg120b-tb \
|
||||
esp8266-esp-12x \
|
||||
esp8266-olimex-mod \
|
||||
esp8266-sparkfun-thing \
|
||||
feather-m0 \
|
||||
feather-m0-lora \
|
||||
feather-m0-wifi \
|
||||
frdm-kl43z \
|
||||
frdm-kw41z \
|
||||
hamilton \
|
||||
i-nucleo-lrwan1 \
|
||||
ikea-tradfri \
|
||||
im880b \
|
||||
lobaro-lorabox \
|
||||
lsn50 \
|
||||
maple-mini \
|
||||
microbit \
|
||||
nrf51dk \
|
||||
nrf51dongle \
|
||||
nrf6310 \
|
||||
nucleo-c031c6 \
|
||||
nucleo-f030r8 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-f070rb \
|
||||
nucleo-f072rb \
|
||||
nucleo-f091rc \
|
||||
nucleo-f103rb \
|
||||
nucleo-f302r8 \
|
||||
nucleo-f303k8 \
|
||||
nucleo-f334r8 \
|
||||
nucleo-f410rb \
|
||||
nucleo-g070rb \
|
||||
nucleo-g071rb \
|
||||
nucleo-g431kb \
|
||||
nucleo-g431rb \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
nucleo-l073rz \
|
||||
nucleo-l412kb \
|
||||
nucleo-l432kc \
|
||||
nucleo-wl55jc \
|
||||
olimexino-stm32 \
|
||||
opencm904 \
|
||||
openlabs-kw41z-mini-256kib \
|
||||
pba-d-01-kw2x \
|
||||
phynode-kw41z \
|
||||
samd10-xmini \
|
||||
samd20-xpro \
|
||||
samd21-xpro \
|
||||
saml10-xpro \
|
||||
saml11-xpro \
|
||||
saml21-xpro \
|
||||
samr21-xpro \
|
||||
samr30-xpro \
|
||||
samr34-xpro \
|
||||
seeeduino_xiao \
|
||||
sensebox_samd21 \
|
||||
serpente \
|
||||
slstk3400a \
|
||||
slstk3401a \
|
||||
sltb001a \
|
||||
slwstk6000b-slwrb4150a \
|
||||
slwstk6220a \
|
||||
sodaq-autonomo \
|
||||
sodaq-explorer \
|
||||
sodaq-one \
|
||||
sodaq-sara-aff \
|
||||
sodaq-sara-sff \
|
||||
spark-core \
|
||||
stk3200 \
|
||||
stk3600 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32f3discovery \
|
||||
stm32f7508-dk \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
stm32mp157c-dk2 \
|
||||
teensy31 \
|
||||
usb-kw41z \
|
||||
weact-f401cc \
|
||||
weact-g030f6 \
|
||||
wemos-zero \
|
||||
yarm \
|
||||
yunjia-nrf51822 \
|
||||
#
|
||||
|
||||
@ -17,17 +17,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "kernel_defines.h"
|
||||
#if IS_USED(MODULE_TENSORFLOW_LITE)
|
||||
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
|
||||
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
||||
#include "tensorflow/lite/micro/micro_interpreter.h"
|
||||
#include "tensorflow/lite/version.h"
|
||||
#else
|
||||
#include "tensorflow/lite/micro/all_ops_resolver.h"
|
||||
#include "tensorflow/lite/micro/micro_error_reporter.h"
|
||||
|
||||
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
|
||||
#include "tensorflow/lite/micro/micro_interpreter.h"
|
||||
#include "tensorflow/lite/micro/system_setup.h"
|
||||
#endif
|
||||
|
||||
#include "tensorflow/lite/schema/schema_generated.h"
|
||||
|
||||
#include "blob/digit.h"
|
||||
@ -37,7 +31,6 @@
|
||||
|
||||
// Globals, used for compatibility with Arduino-style sketches.
|
||||
namespace {
|
||||
tflite::ErrorReporter* error_reporter = nullptr;
|
||||
const tflite::Model* model = nullptr;
|
||||
tflite::MicroInterpreter* interpreter = nullptr;
|
||||
TfLiteTensor* input = nullptr;
|
||||
@ -52,15 +45,6 @@ namespace {
|
||||
// The name of this function is important for Arduino compatibility.
|
||||
void setup()
|
||||
{
|
||||
#if IS_USED(MODULE_TFLITE_MICRO)
|
||||
tflite::InitializeTarget();
|
||||
#endif
|
||||
|
||||
// Set up logging. Google style is to avoid globals or statics because of
|
||||
// lifetime uncertainty, but since this has a trivial destructor it's okay.
|
||||
// NOLINTNEXTLINE(runtime-global-variables)
|
||||
static tflite::MicroErrorReporter micro_error_reporter;
|
||||
error_reporter = µ_error_reporter;
|
||||
|
||||
// Map the model into a usable data structure. This doesn't involve any
|
||||
// copying or parsing, it's a very lightweight operation.
|
||||
@ -74,16 +58,23 @@ void setup()
|
||||
}
|
||||
|
||||
// This pulls in all the operation implementations we need.
|
||||
// NOLINTNEXTLINE(runtime-global-variables)
|
||||
#if IS_USED(MODULE_TFLITE_MICRO)
|
||||
static tflite::AllOpsResolver resolver;
|
||||
#else
|
||||
static tflite::ops::micro::AllOpsResolver resolver;
|
||||
#endif
|
||||
static tflite::MicroMutableOpResolver<4> resolver;
|
||||
if (resolver.AddFullyConnected() != kTfLiteOk) {
|
||||
return;
|
||||
}
|
||||
if (resolver.AddQuantize() != kTfLiteOk) {
|
||||
return;
|
||||
}
|
||||
if (resolver.AddDequantize() != kTfLiteOk) {
|
||||
return;
|
||||
}
|
||||
if (resolver.AddSoftmax() != kTfLiteOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Build an interpreter to run the model with.
|
||||
static tflite::MicroInterpreter static_interpreter(
|
||||
model, resolver, tensor_arena, kTensorArenaSize, error_reporter);
|
||||
model, resolver, tensor_arena, kTensorArenaSize);
|
||||
interpreter = &static_interpreter;
|
||||
|
||||
// Allocate memory from the tensor_arena for the model's tensors.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user