This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 72e5a3cd6 mlearning: bump TFLM to fd2a85d and FlatBuffers to v25.9.23
72e5a3cd6 is described below

commit 72e5a3cd6c0d84331b8f68457fa79e8d49354190
Author: Abhishek Mishra <[email protected]>
AuthorDate: Wed Nov 4 13:35:28 2026 +0000

    mlearning: bump TFLM to fd2a85d and FlatBuffers to v25.9.23
    
    TFLM tip requires FlatBuffers 25.9.23 and a newer CMSIS-NN pin. Rework
    the NuttX patches for the micro/ namespace layout, refresh the source
    globs, and point tflm_tool at micro/schema and flatbuffer_utils.
    
    Validated on sim:tflm (tflm_hello and tflm -I/-E/-n) with no board.
    
    Signed-off-by: Abhishek Mishra <[email protected]>
---
 mlearning/cmsis-nn/CMakeLists.txt                  |  2 +-
 mlearning/cmsis-nn/Makefile                        |  2 +-
 mlearning/tflite-micro/0001-dequantize-int8.patch  | 63 +++-----------
 mlearning/tflite-micro/0002-quantize-int8.patch    | 73 +++++------------
 mlearning/tflite-micro/0003-mean-int8.patch        | 66 ++++++---------
 mlearning/tflite-micro/CMakeLists.txt              | 26 +++---
 mlearning/tflite-micro/Makefile                    | 23 +++---
 .../tflite-micro/operators/neon/arm_convolve_s8.c  | 95 +++++++++++++++++++---
 mlearning/tflite-micro/tflite-micro.patch          | 32 --------
 mlearning/tflite-micro/tflm_tool.cc                |  8 +-
 system/flatbuffers/CMakeLists.txt                  |  2 +-
 system/flatbuffers/Makefile                        |  2 +-
 system/flatbuffers/flatbuffers.patch               | 28 +++----
 13 files changed, 184 insertions(+), 238 deletions(-)

diff --git a/mlearning/cmsis-nn/CMakeLists.txt 
b/mlearning/cmsis-nn/CMakeLists.txt
index 8db8c75d4..94826f3f1 100644
--- a/mlearning/cmsis-nn/CMakeLists.txt
+++ b/mlearning/cmsis-nn/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CONFIG_MLEARNING_CMSIS_NN)
 
   if(NOT EXISTS ${CMSIS_NN_DIR})
     set(CMSIS_NN_URL
-        
https://github.com/ARM-software/CMSIS-NN/archive/72e1ebf623ab1660a3e14e4e36fdcddce46f1991.zip
+        
https://github.com/ARM-software/CMSIS-NN/archive/18bb0fd4ecea4b17a5a3c444c8d3a8cf28b1e68f.zip
     )
     FetchContent_Declare(
       cmsis_nn_fetch
diff --git a/mlearning/cmsis-nn/Makefile b/mlearning/cmsis-nn/Makefile
index cd8117275..56f1778aa 100644
--- a/mlearning/cmsis-nn/Makefile
+++ b/mlearning/cmsis-nn/Makefile
@@ -24,7 +24,7 @@ include $(APPDIR)/Make.defs
 
 CMSIS_NN = cmsis-nn/Source
 
-CMSIS_NN_VER = 72e1ebf623ab1660a3e14e4e36fdcddce46f1991
+CMSIS_NN_VER = 18bb0fd4ecea4b17a5a3c444c8d3a8cf28b1e68f
 
 cmsis-nn.zip:
        $(Q) curl -L 
https://github.com/ARM-software/CMSIS-NN/archive/$(CMSIS_NN_VER).zip -o 
cmsis-nn.zip
diff --git a/mlearning/tflite-micro/0001-dequantize-int8.patch 
b/mlearning/tflite-micro/0001-dequantize-int8.patch
index 92babecac..9c06adb9e 100644
--- a/mlearning/tflite-micro/0001-dequantize-int8.patch
+++ b/mlearning/tflite-micro/0001-dequantize-int8.patch
@@ -8,17 +8,12 @@ VELAPLATFO-30990
 Change-Id: I0e741a72464c7e497425175d2fcd63f14ed6897b
 Signed-off-by: jihandong <[email protected]>
 ---
- tensorflow/lite/micro/kernels/dequantize.cc   | 21 +++++++++++++++++++
- tensorflow/lite/micro/kernels/dequantize.h    |  5 ++++-
- .../lite/micro/micro_mutable_op_resolver.h    |  6 ++++--
- 3 files changed, 29 insertions(+), 3 deletions(-)
-
 diff --git a/tensorflow/lite/micro/kernels/dequantize.cc 
b/tensorflow/lite/micro/kernels/dequantize.cc
-index 428c866a..48f50de4 100644
+index cd3678a..08a01a5 100644
 --- a/tensorflow/lite/micro/kernels/dequantize.cc
 +++ b/tensorflow/lite/micro/kernels/dequantize.cc
-@@ -76,9 +76,30 @@ TfLiteStatus DequantizeEval(TfLiteContext* context, 
TfLiteNode* node) {
-   return kTfLiteOk;
+@@ -79,5 +79,26 @@ TFLMRegistration Register_DEQUANTIZE() {
+                                    DequantizeEval);
  }
  
 +TfLiteStatus DequantizeEvalInt8(TfLiteContext* context, TfLiteNode* node) {
@@ -37,65 +32,29 @@ index 428c866a..48f50de4 100644
 +  return kTfLiteOk;
 +}
 +
- TFLMRegistration Register_DEQUANTIZE() {
-   return tflite::micro::RegisterOp(DequantizeInit, DequantizePrepare,
-                                    DequantizeEval);
- }
- 
 +TFLMRegistration Register_DEQUANTIZE_INT8() {
 +  return tflite::micro::RegisterOp(DequantizeInit, DequantizePrepare,
 +                                   DequantizeEvalInt8);
 +}
 +
+ }  // namespace micro
  }  // namespace tflite
 diff --git a/tensorflow/lite/micro/kernels/dequantize.h 
b/tensorflow/lite/micro/kernels/dequantize.h
-index fe6ec169..3dede725 100644
+index a69af8c..f0caedd 100644
 --- a/tensorflow/lite/micro/kernels/dequantize.h
 +++ b/tensorflow/lite/micro/kernels/dequantize.h
-@@ -17,8 +17,8 @@ limitations under the License.
- #define TENSORFLOW_LITE_MICRO_KERNELS_DEQUANTIZE_H_
- 
- #include "tensorflow/lite/c/builtin_op_data.h"
--#include "tensorflow/lite/c/common.h"
- #include "tensorflow/lite/kernels/internal/types.h"
-+#include "tensorflow/lite/micro/micro_common.h"
- 
- namespace tflite {
- 
-@@ -33,6 +33,9 @@ struct DequantizeOpData {
+@@ -33,9 +33,14 @@ struct DequantizeOpData {
  
  TfLiteStatus DequantizePrepare(TfLiteContext* context, TfLiteNode* node);
  
 +TFLMRegistration Register_DEQUANTIZE();
 +TFLMRegistration Register_DEQUANTIZE_INT8();
 +
+ }  // namespace micro
+ 
+ using micro::DequantizeOpData;
++using micro::Register_DEQUANTIZE;
++using micro::Register_DEQUANTIZE_INT8;
  }  // namespace tflite
  
  #endif  // TENSORFLOW_LITE_MICRO_KERNELS_DEQUANTIZE_H_
-diff --git a/tensorflow/lite/micro/micro_mutable_op_resolver.h 
b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-index f5f6e38e..b3e3cbcf 100644
---- a/tensorflow/lite/micro/micro_mutable_op_resolver.h
-+++ b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-@@ -26,6 +26,7 @@ limitations under the License.
- #include "tensorflow/lite/micro/kernels/add.h"
- #include "tensorflow/lite/micro/kernels/conv.h"
- #include "tensorflow/lite/micro/kernels/depthwise_conv.h"
-+#include "tensorflow/lite/micro/kernels/dequantize.h"
- #include "tensorflow/lite/micro/kernels/ethosu.h"
- #include "tensorflow/lite/micro/kernels/fully_connected.h"
- #include "tensorflow/lite/micro/kernels/micro_ops.h"
-@@ -217,8 +218,9 @@ class MicroMutableOpResolver : public MicroOpResolver {
-                       ParseDepthwiseConv2D);
-   }
- 
--  TfLiteStatus AddDequantize() {
--    return AddBuiltin(BuiltinOperator_DEQUANTIZE, 
tflite::Register_DEQUANTIZE(),
-+  TfLiteStatus AddDequantize(
-+      const TFLMRegistration& registration = Register_DEQUANTIZE()) {
-+    return AddBuiltin(BuiltinOperator_DEQUANTIZE, registration,
-                       ParseDequantize);
-   }
- 
--- 
-2.25.1
-
diff --git a/mlearning/tflite-micro/0002-quantize-int8.patch 
b/mlearning/tflite-micro/0002-quantize-int8.patch
index 138eea987..8489c177e 100644
--- a/mlearning/tflite-micro/0002-quantize-int8.patch
+++ b/mlearning/tflite-micro/0002-quantize-int8.patch
@@ -10,58 +10,52 @@ Separate the 'Float32 to Int8' implementation of the 
'quantize' operator to redu
 Change-Id: I83dc809d36587741f3087b25e83e454b30f9626b
 Signed-off-by: xinhaiteng <[email protected]>
 ---
- tensorflow/lite/micro/kernels/quantize.cc        |  5 +++++
- tensorflow/lite/micro/kernels/quantize.h         |  4 ++++
- tensorflow/lite/micro/kernels/quantize_common.cc | 16 ++++++++++++++++
- .../lite/micro/micro_mutable_op_resolver.h       |  7 ++++---
- 4 files changed, 29 insertions(+), 3 deletions(-)
-
 diff --git a/tensorflow/lite/micro/kernels/quantize.cc 
b/tensorflow/lite/micro/kernels/quantize.cc
-index ba11f19b6..a6ff4f055 100644
+index cb5b89e..38d1cc4 100644
 --- a/tensorflow/lite/micro/kernels/quantize.cc
 +++ b/tensorflow/lite/micro/kernels/quantize.cc
-@@ -39,4 +39,9 @@ TFLMRegistration Register_QUANTIZE() {
+@@ -38,5 +38,11 @@ TFLMRegistration Register_QUANTIZE() {
        InitQuantizeReference, PrepareQuantizeReference, EvalQuantizeReference);
  }
  
 +TFLMRegistration Register_QUANTIZE_FLOAT32_INT8() {
-+  return tflite::micro::RegisterOp(
-+      InitQuantizeReference, PrepareQuantizeReference, 
EvalQuantizeReferenceFloat32ToInt8);
++  return tflite::micro::RegisterOp(InitQuantizeReference,
++                                   PrepareQuantizeReference,
++                                   EvalQuantizeReferenceFloat32ToInt8);
 +}
 +
+ }  // namespace micro
  }  // namespace tflite
 diff --git a/tensorflow/lite/micro/kernels/quantize.h 
b/tensorflow/lite/micro/kernels/quantize.h
-index ba93809a2..b97e4a2ab 100644
+index ec650f2..eaec891 100644
 --- a/tensorflow/lite/micro/kernels/quantize.h
 +++ b/tensorflow/lite/micro/kernels/quantize.h
-@@ -17,6 +17,7 @@ limitations under the License.
- 
- #include "tensorflow/lite/c/common.h"
- #include "tensorflow/lite/kernels/internal/types.h"
-+#include "tensorflow/lite/micro/micro_common.h"
- 
- namespace tflite {
- 
-@@ -31,7 +32,10 @@ struct OpDataQuantizeReference {
+@@ -31,10 +31,15 @@ struct OpDataQuantizeReference {
  };
  
  TfLiteStatus EvalQuantizeReference(TfLiteContext* context, TfLiteNode* node);
-+TfLiteStatus EvalQuantizeReferenceFloat32ToInt8(TfLiteContext* context, 
TfLiteNode* node);
++TfLiteStatus EvalQuantizeReferenceFloat32ToInt8(TfLiteContext* context,
++                                                TfLiteNode* node);
  TfLiteStatus PrepareQuantizeReference(TfLiteContext* context, TfLiteNode* 
node);
-+
+ 
 +TFLMRegistration Register_QUANTIZE_FLOAT32_INT8();
++
+ }  // namespace micro
+ using micro::OpDataQuantizeReference;
++using micro::Register_QUANTIZE_FLOAT32_INT8;
  }  // namespace tflite
  
  #endif  // TENSORFLOW_LITE_MICRO_KERNELS_QUANTIZE_H_
 diff --git a/tensorflow/lite/micro/kernels/quantize_common.cc 
b/tensorflow/lite/micro/kernels/quantize_common.cc
-index cb04eafce..6bdd0df39 100644
+index 8ac4c99..8da41cc 100644
 --- a/tensorflow/lite/micro/kernels/quantize_common.cc
 +++ b/tensorflow/lite/micro/kernels/quantize_common.cc
-@@ -236,4 +236,20 @@ TfLiteStatus EvalQuantizeReference(TfLiteContext* 
context, TfLiteNode* node) {
+@@ -235,5 +235,22 @@ TfLiteStatus EvalQuantizeReference(TfLiteContext* 
context, TfLiteNode* node) {
    return kTfLiteOk;
  }
  
-+TfLiteStatus EvalQuantizeReferenceFloat32ToInt8(TfLiteContext* context, 
TfLiteNode* node) {
++TfLiteStatus EvalQuantizeReferenceFloat32ToInt8(TfLiteContext* context,
++                                                TfLiteNode* node) {
 +  TFLITE_DCHECK(node->user_data != nullptr);
 +  auto* data = static_cast<OpDataQuantizeReference*>(node->user_data);
 +
@@ -77,32 +71,5 @@ index cb04eafce..6bdd0df39 100644
 +  return kTfLiteOk;
 +}
 +
+ }  // namespace micro
  }  // namespace tflite
-diff --git a/tensorflow/lite/micro/micro_mutable_op_resolver.h 
b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-index b3e3cbcf8..ec8979c4e 100644
---- a/tensorflow/lite/micro/micro_mutable_op_resolver.h
-+++ b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-@@ -32,6 +32,7 @@ limitations under the License.
- #include "tensorflow/lite/micro/kernels/micro_ops.h"
- #include "tensorflow/lite/micro/kernels/mul.h"
- #include "tensorflow/lite/micro/kernels/pooling.h"
-+#include "tensorflow/lite/micro/kernels/quantize.h"
- #include "tensorflow/lite/micro/kernels/reduce.h"
- #include "tensorflow/lite/micro/kernels/softmax.h"
- #include "tensorflow/lite/micro/kernels/transpose_conv.h"
-@@ -481,9 +482,9 @@ class MicroMutableOpResolver : public MicroOpResolver {
-                       ParsePrelu);
-   }
- 
--  TfLiteStatus AddQuantize() {
--    return AddBuiltin(BuiltinOperator_QUANTIZE, Register_QUANTIZE(),
--                      ParseQuantize);
-+  TfLiteStatus AddQuantize(
-+      const TFLMRegistration& registration = Register_QUANTIZE()) {
-+    return AddBuiltin(BuiltinOperator_QUANTIZE, registration, ParseQuantize);
-   }
- 
-   TfLiteStatus AddReadVariable() {
--- 
-2.25.1
-
diff --git a/mlearning/tflite-micro/0003-mean-int8.patch 
b/mlearning/tflite-micro/0003-mean-int8.patch
index de45afe8b..e29fa88ce 100644
--- a/mlearning/tflite-micro/0003-mean-int8.patch
+++ b/mlearning/tflite-micro/0003-mean-int8.patch
@@ -10,17 +10,11 @@ Separate the Int8 implementation of the 'mean' operator to 
reduce the code size.
 Change-Id: I5eb9e3cc939668b6531ef9e56f7c32090f1de141
 Signed-off-by: xinhaiteng <[email protected]>
 ---
- tensorflow/lite/micro/kernels/reduce.cc          |  9 +++++++++
- tensorflow/lite/micro/kernels/reduce.h           |  3 +++
- tensorflow/lite/micro/kernels/reduce_common.cc   | 16 ++++++++++++++++
- .../lite/micro/micro_mutable_op_resolver.h       |  5 +++--
- 4 files changed, 31 insertions(+), 2 deletions(-)
-
 diff --git a/tensorflow/lite/micro/kernels/reduce.cc 
b/tensorflow/lite/micro/kernels/reduce.cc
-index a689d3b93..090bafc3c 100644
+index 5a4bfc4..a3b7ce9 100644
 --- a/tensorflow/lite/micro/kernels/reduce.cc
 +++ b/tensorflow/lite/micro/kernels/reduce.cc
-@@ -49,6 +49,11 @@ TfLiteStatus EvalMean(TfLiteContext* context, TfLiteNode* 
node) {
+@@ -55,6 +55,11 @@ TfLiteStatus EvalMean(TfLiteContext* context, TfLiteNode* 
node) {
                          static_cast<OpDataReduce*>(node->user_data));
  }
  
@@ -32,7 +26,7 @@ index a689d3b93..090bafc3c 100644
  TfLiteStatus EvalMax(TfLiteContext* context, TfLiteNode* node) {
    OpDataReduce* op_data = static_cast<OpDataReduce*>(node->user_data);
    return EvalMaxHelper(context, node, op_data);
-@@ -63,6 +68,10 @@ TFLMRegistration Register_MEAN() {
+@@ -81,6 +86,10 @@ TFLMRegistration Register_MEAN() {
    return tflite::micro::RegisterOp(InitReduce, PrepareMeanOrSum, EvalMean);
  }
  
@@ -41,13 +35,13 @@ index a689d3b93..090bafc3c 100644
 +}
 +
  TFLMRegistration Register_REDUCE_MAX() {
-   return tflite::micro::RegisterOp(InitReduce, PrepareMax, EvalMax);
+   return tflite::micro::RegisterOp(InitReduce, PrepareMinMax, EvalMax);
  }
 diff --git a/tensorflow/lite/micro/kernels/reduce.h 
b/tensorflow/lite/micro/kernels/reduce.h
-index 2daeef5fe..0e29b3af8 100644
+index 6d7808f..abbdc03 100644
 --- a/tensorflow/lite/micro/kernels/reduce.h
 +++ b/tensorflow/lite/micro/kernels/reduce.h
-@@ -50,6 +50,8 @@ TfLiteStatus EvalMaxHelper(TfLiteContext* context, 
TfLiteNode* node,
+@@ -53,12 +53,15 @@ TfLiteStatus EvalMinHelper(TfLiteContext* context, 
TfLiteNode* node,
                             OpDataReduce* op_data);
  TfLiteStatus EvalMeanHelper(TfLiteContext* context, TfLiteNode* node,
                              OpDataReduce* op_data);
@@ -55,20 +49,27 @@ index 2daeef5fe..0e29b3af8 100644
 +                                OpDataReduce* op_data);
  TfLiteStatus EvalSumHelper(TfLiteContext* context, TfLiteNode* node,
                             OpDataReduce* op_data);
- 
-@@ -57,6 +59,7 @@ void ReduceResolveAxis(const int* axis_data, int axis_count,
-                        MeanParams* op_params);
+ TfLiteStatus EvalAllHelper(TfLiteContext* context, TfLiteNode* node,
+                            OpDataReduce* op_data);
  
  TFLMRegistration Register_MEAN();
 +TFLMRegistration Register_MEAN_INT8();
  TFLMRegistration Register_REDUCE_MAX();
+ TFLMRegistration Register_REDUCE_MIN();
  TFLMRegistration Register_SUM();
- 
+@@ -67,6 +70,7 @@ TFLMRegistration Register_REDUCE_ALL();
+ }  // namespace micro
+ using micro::OpDataReduce;
+ using micro::Register_MEAN;
++using micro::Register_MEAN_INT8;
+ using micro::Register_REDUCE_ALL;
+ using micro::Register_REDUCE_MAX;
+ using micro::Register_REDUCE_MIN;
 diff --git a/tensorflow/lite/micro/kernels/reduce_common.cc 
b/tensorflow/lite/micro/kernels/reduce_common.cc
-index 2c1a92a50..6e4ab1cc9 100644
+index 4fe6347..6172bb1 100644
 --- a/tensorflow/lite/micro/kernels/reduce_common.cc
 +++ b/tensorflow/lite/micro/kernels/reduce_common.cc
-@@ -236,6 +236,22 @@ TfLiteStatus EvalMeanHelper(TfLiteContext* context, 
TfLiteNode* node,
+@@ -349,6 +349,24 @@ TfLiteStatus EvalMeanHelper(TfLiteContext* context, 
TfLiteNode* node,
    return kTfLiteOk;
  }
  
@@ -78,35 +79,18 @@ index 2c1a92a50..6e4ab1cc9 100644
 +  const TfLiteEvalTensor* axis = tflite::micro::GetEvalInput(context, node, 
1);
 +
 +  int num_axis = static_cast<int>(ElementCount(*axis->dims));
-+  int temp_index[kMaxNumberOfAxis];
-+  int resolved_axis[kMaxNumberOfReducedAxis];
++  int* input_iter = static_cast<int*>(
++      context->GetScratchBuffer(context, op_data->scratch_input_iter_idx));
++  int* resolved_axis = static_cast<int*>(
++      context->GetScratchBuffer(context, op_data->scratch_resolved_axis_idx));
 +
 +  TFLITE_DCHECK(input->type == kTfLiteInt8);
 +  TF_LITE_ENSURE_OK(
 +      context, EvalIntegerMean<int8_t>(context, node, num_axis, op_data,
-+                                        temp_index, resolved_axis));
++                                       input_iter, resolved_axis));
 +  return kTfLiteOk;
 +}
 +
  TfLiteStatus EvalMaxHelper(TfLiteContext* context, TfLiteNode* node,
                             OpDataReduce* op_data) {
-   const TfLiteEvalTensor* input = tflite::micro::GetEvalInput(context, node, 
0);
-diff --git a/tensorflow/lite/micro/micro_mutable_op_resolver.h 
b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-index ec8979c4e..253f83de1 100644
---- a/tensorflow/lite/micro/micro_mutable_op_resolver.h
-+++ b/tensorflow/lite/micro/micro_mutable_op_resolver.h
-@@ -432,8 +432,9 @@ class MicroMutableOpResolver : public MicroOpResolver {
-                       ParseMirrorPad);
-   }
- 
--  TfLiteStatus AddMean() {
--    return AddBuiltin(BuiltinOperator_MEAN, Register_MEAN(), ParseReducer);
-+  TfLiteStatus AddMean(
-+      const TFLMRegistration& registration = Register_MEAN()) {
-+    return AddBuiltin(BuiltinOperator_MEAN, registration, ParseReducer);
-   }
- 
-   TfLiteStatus AddMinimum() {
--- 
-2.25.1
-
+   return EvalMinMaxHelper(context, node, op_data, kEvalMax);
diff --git a/mlearning/tflite-micro/CMakeLists.txt 
b/mlearning/tflite-micro/CMakeLists.txt
index af44b7020..a8d33f243 100644
--- a/mlearning/tflite-micro/CMakeLists.txt
+++ b/mlearning/tflite-micro/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CONFIG_TFLITEMICRO)
 
   if(NOT EXISTS ${TFLITE_MICRO_DIR})
     set(TFLITE_MICRO_URL
-        
https://github.com/tensorflow/tflite-micro/archive/cfa4c91d1b36c37c7c104b9c664615e59f1abfe3.zip
+        
https://github.com/tensorflow/tflite-micro/archive/fd2a85dfb3bedac81920e8667565b1044c6b6a43.zip
     )
     FetchContent_Declare(
       tflite_micro_fetch
@@ -38,8 +38,6 @@ if(CONFIG_TFLITEMICRO)
           ${NUTTX_BINARY_DIR}/apps/mlearning/tflite-micro/tflite-micro
       PATCH_COMMAND
         patch -d ${TFLITE_MICRO_DIR} -p1 <
-        ${CMAKE_CURRENT_LIST_DIR}/tflite-micro.patch && patch -d
-        ${TFLITE_MICRO_DIR} -p1 <
         ${CMAKE_CURRENT_LIST_DIR}/0001-dequantize-int8.patch && patch -d
         ${TFLITE_MICRO_DIR} -p1 <
         ${CMAKE_CURRENT_LIST_DIR}/0002-quantize-int8.patch && patch -d
@@ -85,22 +83,20 @@ if(CONFIG_TFLITEMICRO)
   file(
     GLOB
     TFLITE_MICRO_SRCS
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/kernels/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/c/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/schema/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/core/c/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/kernels/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/kernels/internal/optimized/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/kernels/internal/reference/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/kernels/internal/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/core/api/*.cc
+    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/*.cc
     ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/arena_allocator/*.cc
     ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/memory_planner/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/*.cc
-    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/tflite_bridge/*.cc)
+    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/kernels/*.cc
+    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/kernels/internal/*.cc
+    ${TFLITE_MICRO_DIR}/tensorflow/lite/micro/kernels/internal/reference/*.cc)
 
-  # Remove test file
+  # Remove test / host-only helpers
   list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*test.cc")
+  list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*fake_micro_context.cc")
+  list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*mock_micro_graph.cc")
+  list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*test_helpers.cc")
+  list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*test_helper_custom_ops.cc")
+  list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX ".*kernel_runner.cc")
   if(CONFIG_TFLITEMICRO_SYSLOG)
     list(FILTER TFLITE_MICRO_SRCS EXCLUDE REGEX "micro_log.cc")
     list(APPEND TFLITE_MICRO_SRCS ${CMAKE_CURRENT_LIST_DIR}/tflm_syslog.cc)
diff --git a/mlearning/tflite-micro/Makefile b/mlearning/tflite-micro/Makefile
index 7d23bc5d1..e400e9e82 100644
--- a/mlearning/tflite-micro/Makefile
+++ b/mlearning/tflite-micro/Makefile
@@ -27,14 +27,13 @@ CXXEXT       := .cc
 CXXSRCS      :=
 COMMON_FLAGS :=
 TFLM_UNPACK  := tflite-micro
-TFLM_VER     := cfa4c91d1b36c37c7c104b9c664615e59f1abfe3
+TFLM_VER     := fd2a85dfb3bedac81920e8667565b1044c6b6a43
 TFLM_DIR     := $(APPDIR)/mlearning/tflite-micro/$(TFLM_UNPACK)
 
 tflite-micro.zip:
        $(Q) curl -L 
https://github.com/tensorflow/tflite-micro/archive/$(TFLM_VER).zip -o 
tflite-micro.zip
        $(Q) unzip -o tflite-micro.zip
        $(Q) mv tflite-micro-$(TFLM_VER) $(TFLM_UNPACK)
-       $(Q) patch -d $(TFLM_UNPACK) -p1 < tflite-micro.patch
        $(Q) patch -d $(TFLM_UNPACK) -p1 < 0001-dequantize-int8.patch
        $(Q) patch -d $(TFLM_UNPACK) -p1 < 0002-quantize-int8.patch
        $(Q) patch -d $(TFLM_UNPACK) -p1 < 0003-mean-int8.patch
@@ -68,21 +67,19 @@ ifeq 
($(CONFIG_TFLITEMICRO_DEBUG)$(CONFIG_TFLITEMICRO_SYSLOG),)
 COMMON_FLAGS += -DTF_LITE_STRIP_ERROR_STRINGS
 endif
 
-# tflite micro
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/c/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/core/c/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/core/api/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/kernels/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/kernels/internal/*.cc)
-CXXSRCS += $(wildcard 
$(TFLM_DIR)/tensorflow/lite/kernels/internal/optimized/*.cc)
-CXXSRCS += $(wildcard 
$(TFLM_DIR)/tensorflow/lite/kernels/internal/reference/*.cc)
+# tflite micro (layout as of TFLM fd2a85dfb3bedac81920e8667565b1044c6b6a43)
 CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/*.cc)
 CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/arena_allocator/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/kernels/*.cc)
 CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/memory_planner/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/tflite_bridge/*.cc)
-CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/schema/*.cc)
+CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/kernels/*.cc)
+CXXSRCS += $(wildcard $(TFLM_DIR)/tensorflow/lite/micro/kernels/internal/*.cc)
+CXXSRCS += $(wildcard 
$(TFLM_DIR)/tensorflow/lite/micro/kernels/internal/reference/*.cc)
 CXXSRCS := $(filter-out %test.cc, $(CXXSRCS))
+CXXSRCS := $(filter-out %fake_micro_context.cc, $(CXXSRCS))
+CXXSRCS := $(filter-out %mock_micro_graph.cc, $(CXXSRCS))
+CXXSRCS := $(filter-out %test_helpers.cc, $(CXXSRCS))
+CXXSRCS := $(filter-out %test_helper_custom_ops.cc, $(CXXSRCS))
+CXXSRCS := $(filter-out %kernel_runner.cc, $(CXXSRCS))
 
 ifneq ($(CONFIG_TFLITEMICRO_SYSLOG),)
   CXXSRCS := $(filter-out %micro_log.cc, $(CXXSRCS))
diff --git a/mlearning/tflite-micro/operators/neon/arm_convolve_s8.c 
b/mlearning/tflite-micro/operators/neon/arm_convolve_s8.c
index 64a3150e1..73106b709 100644
--- a/mlearning/tflite-micro/operators/neon/arm_convolve_s8.c
+++ b/mlearning/tflite-micro/operators/neon/arm_convolve_s8.c
@@ -34,7 +34,7 @@
  *
  * Refer header file for details. Optimal use case for the DSP/MVE
  * implementation is when input and output channels are multiples of 4 or
- * atleast greater than 4.
+ * at least greater than 4.
  */
 
 arm_cmsis_nn_status
@@ -47,6 +47,7 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
                 const int8_t *filter_data,
                 const cmsis_nn_dims *bias_dims,
                 const int32_t *bias_data,
+                const cmsis_nn_dims *upscale_dims,
                 const cmsis_nn_dims *output_dims,
                 int8_t *output_data)
 {
@@ -81,10 +82,27 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
   const int32_t rhs_cols = kernel_x * kernel_y * input_ch;
   const int32_t input_offset = conv_params->input_offset;
 
+  /* Match CMSIS-NN: upscale_dims->h/w == 2 inserts zeroes for transposed
+   * convolution. Index into the real input via rshift.
+   */
+
+  uint32_t y_rshift = 0;
+  uint32_t x_rshift = 0;
+
+  if (upscale_dims)
+    {
+      y_rshift = upscale_dims->h == 2 ? 1 : 0;
+      x_rshift = upscale_dims->w == 2 ? 1 : 0;
+    }
+
+  const int32_t input_x_rshifted = input_x >> x_rshift;
+  const int32_t input_y_rshifted = input_y >> y_rshift;
+
   int32_t *output_mult = quant_params->multiplier;
   int32_t *output_shift = quant_params->shift;
 
   int i_batch;
+
   for (i_batch = 0; i_batch < input_batches; i_batch++)
     {
       const int32_t remainder = rhs_cols % 4;
@@ -106,20 +124,74 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
       for (int i_out_x = 0; i_out_x < output_x; i_out_x++)
         {
           const int32_t base_idx_x = stride_x * i_out_x - pad_x;
+
           for (int i_out_y = 0; i_out_y < output_y; i_out_y++)
             {
               const int32_t base_idx_y = stride_y * i_out_y - pad_y;
-              for (int32_t i_ker_x = 0; i_ker_x < kernel_x; i_ker_x++)
+
+              if (y_rshift == 1 || x_rshift == 1)
                 {
-                  int32_t k_x = base_idx_x + dilation_x * i_ker_x;
-                  int32_t k_y = base_idx_y - dilation_y;
+                  /* Fill with -input_offset; copy only even (non-inserted)
+                   * rows/cols, matching CMSIS-NN arm_convolve_s8().
+                   */
+
+                  arm_memset_s8(im2col_buf, (int8_t)-input_offset,
+                                input_ch * kernel_x * kernel_y);
                   for (int32_t i_ker_y = 0; i_ker_y < kernel_y; i_ker_y++)
                     {
-                      k_y += dilation_y;
-                      arm_memcpy_s8(im2col_buf,
-                          input_data + (k_y * input_x + k_x) * input_ch,
-                          input_ch);
-                      im2col_buf += input_ch;
+                      const int32_t k_y = base_idx_y + dilation_y * i_ker_y;
+
+                      if ((k_y < 0 || k_y >= input_y) ||
+                          (k_y % 2 && y_rshift == 1))
+                        {
+                          im2col_buf += input_ch * kernel_x;
+                        }
+                      else
+                        {
+                          const int32_t k_y_rshifted = k_y >> y_rshift;
+
+                          for (int32_t i_ker_x = 0; i_ker_x < kernel_x;
+                               i_ker_x++)
+                            {
+                              const int32_t k_x =
+                                  base_idx_x + dilation_x * i_ker_x;
+
+                              if ((k_x >= 0 && k_x < input_x) &&
+                                  ((k_x % 2 == 0) ||
+                                   x_rshift == 0))
+                                {
+                                  const int32_t k_x_rshifted =
+                                      k_x >> x_rshift;
+
+                                  arm_memcpy_s8(
+                                      im2col_buf,
+                                      input_data +
+                                          (k_y_rshifted * input_x_rshifted +
+                                           k_x_rshifted) * input_ch,
+                                      input_ch);
+                                }
+
+                              im2col_buf += input_ch;
+                            }
+                        }
+                    }
+                }
+              else
+                {
+                  for (int32_t i_ker_x = 0; i_ker_x < kernel_x; i_ker_x++)
+                    {
+                      int32_t k_x = base_idx_x + dilation_x * i_ker_x;
+                      int32_t k_y = base_idx_y - dilation_y;
+
+                      for (int32_t i_ker_y = 0; i_ker_y < kernel_y;
+                           i_ker_y++)
+                        {
+                          k_y += dilation_y;
+                          arm_memcpy_s8(im2col_buf,
+                              input_data + (k_y * input_x + k_x) * input_ch,
+                              input_ch);
+                          im2col_buf += input_ch;
+                        }
                     }
                 }
 
@@ -169,6 +241,7 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
               int32_t sum = 0;
               const int16_t *ip_as_col = buffer_a;
               int32x4_t res_s32 = vdupq_n_s32(0);
+
               if (bias_data)
                 {
                   sum = bias_data[i];
@@ -179,6 +252,7 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
                   int8x8_t filter_s8 = vld1_s8(ker_a);
                   int16x8_t input_s16 = vld1q_s16(ip_as_col);
                   int16x8_t filter_s16 = vmovl_s8(filter_s8);
+
                   ker_a += 8;
                   ip_as_col += 8;
                   res_s32 = vmlal_s16(res_s32,
@@ -199,6 +273,7 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
                 {
                   int8_t ker_a1 = *ker_a++;
                   int16_t ip_b1 = *ip_as_col++;
+
                   sum += ker_a1 * ip_b1;
                   col_count--;
                 }
@@ -214,7 +289,7 @@ arm_convolve_s8(const cmsis_nn_context *ctx,
 
       /* Advance to the next batch */
 
-      input_data += (input_x * input_y * input_ch);
+      input_data += (input_x_rshifted * input_y_rshifted * input_ch);
       output_data += (output_x * output_y * output_ch);
     }
 
diff --git a/mlearning/tflite-micro/tflite-micro.patch 
b/mlearning/tflite-micro/tflite-micro.patch
deleted file mode 100644
index 7c39ee527..000000000
--- a/mlearning/tflite-micro/tflite-micro.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From e6049c8ddd7e36db4993e3c6d8b4e5a7114db2c5 Mon Sep 17 00:00:00 2001
-From: renzhiyuan1 <[email protected]>
-Date: Mon, 4 Dec 2023 12:30:20 +0800
-Subject: [PATCH] Patch files in tflite-micro
-
-VELAPLATFO-20049
-
-Patch files in tflite-micro
-
-Change-Id: Ic683fe4f12221d214ca77515c7b9487bb76a923f
-Signed-off-by: renzhiyuan1 <[email protected]>
----
- signal/src/circular_buffer.cc | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/signal/src/circular_buffer.cc b/signal/src/circular_buffer.cc
-index 7638d912e..3261be56c 100644
---- a/signal/src/circular_buffer.cc
-+++ b/signal/src/circular_buffer.cc
-@@ -19,7 +19,9 @@ limitations under the License.
- #include <stdlib.h>
- #include <string.h>
- 
-+#ifndef ASSERT
- #define ASSERT assert
-+#endif
- 
- namespace tflite {
- namespace tflm_signal {
--- 
-2.25.1
-
diff --git a/mlearning/tflite-micro/tflm_tool.cc 
b/mlearning/tflite-micro/tflm_tool.cc
index 02efdb22f..2479545d3 100644
--- a/mlearning/tflite-micro/tflm_tool.cc
+++ b/mlearning/tflite-micro/tflm_tool.cc
@@ -42,8 +42,8 @@
 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
 #include "tensorflow/lite/micro/micro_profiler.h"
 #include "tensorflow/lite/micro/micro_utils.h"
-#include "tensorflow/lite/schema/schema_generated.h"
-#include "tensorflow/lite/schema/schema_utils.h"
+#include "tensorflow/lite/micro/flatbuffer_utils.h"
+#include "tensorflow/lite/micro/schema/schema_generated.h"
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -462,7 +462,7 @@ static int register_ops(FAR const tflite::Model *model,
 
   for (i = 0; i < codes->size(); i++)
     {
-      op = tflite::GetBuiltinCode(codes->Get(i));
+      op = tflite::micro::GetBuiltinCode(codes->Get(i));
       if (op == tflite::BuiltinOperator_CUSTOM)
         {
           printf("Unsupported custom operator: %s\n",
@@ -511,7 +511,7 @@ static void print_model_info(FAR const tflite::Model *model,
   printf("operators: %" PRIu32 "\n", operators->size());
   for (i = 0; i < codes->size(); i++)
     {
-      op = tflite::GetBuiltinCode(codes->Get(i));
+      op = tflite::micro::GetBuiltinCode(codes->Get(i));
       count = 0;
       for (j = 0; j < operators->size(); j++)
         {
diff --git a/system/flatbuffers/CMakeLists.txt 
b/system/flatbuffers/CMakeLists.txt
index c5d89a561..da7466b4f 100644
--- a/system/flatbuffers/CMakeLists.txt
+++ b/system/flatbuffers/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CONFIG_SYSTEM_FLATBUFFERS)
 
   if(NOT EXISTS ${FLATBUFFERS_DIR})
     set(FLATBUFFERS_URL
-        https://github.com/google/flatbuffers/archive/v23.5.26.tar.gz)
+        https://github.com/google/flatbuffers/archive/v25.9.23.tar.gz)
     FetchContent_Declare(
       flatbuffers_fetch
       URL ${FLATBUFFERS_URL} SOURCE_DIR ${FLATBUFFERS_DIR} BINARY_DIR
diff --git a/system/flatbuffers/Makefile b/system/flatbuffers/Makefile
index a0e78caca..955f63d0a 100644
--- a/system/flatbuffers/Makefile
+++ b/system/flatbuffers/Makefile
@@ -22,7 +22,7 @@
 
 include $(APPDIR)/Make.defs
 
-FLATBUFFERS_VER = 23.5.26
+FLATBUFFERS_VER = 25.9.23
 FLATBUFFERS_UNPACK = flatbuffers
 
 flatbuffers.tar.gz:
diff --git a/system/flatbuffers/flatbuffers.patch 
b/system/flatbuffers/flatbuffers.patch
index 2017775aa..791988de5 100644
--- a/system/flatbuffers/flatbuffers.patch
+++ b/system/flatbuffers/flatbuffers.patch
@@ -1,5 +1,5 @@
 diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
-index 5c4cae79..1a631641 100644
+index 987dcbc..0b49748 100644
 --- a/include/flatbuffers/base.h
 +++ b/include/flatbuffers/base.h
 @@ -1,6 +1,16 @@
@@ -20,19 +20,19 @@ index 5c4cae79..1a631641 100644
  
  // If activate should be declared and included first.
 diff --git a/include/flatbuffers/default_allocator.h 
b/include/flatbuffers/default_allocator.h
-index d4724122..975d9380 100644
+index d1cab08..b253b59 100644
 --- a/include/flatbuffers/default_allocator.h
 +++ b/include/flatbuffers/default_allocator.h
 @@ -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) {
+ inline uint8_t* Allocate(Allocator* allocator, size_t size) {
 -  return allocator ? allocator->allocate(size)
 -                   : DefaultAllocator().allocate(size);
 +  return allocator->allocate(size);
  }
  
- inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) {
+ inline void Deallocate(Allocator* allocator, uint8_t* p, size_t size) {
 -  if (allocator)
 -    allocator->deallocate(p, size);
 -  else
@@ -40,7 +40,7 @@ index d4724122..975d9380 100644
 +  allocator->deallocate(p, size);
  }
  
- inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p,
+ inline uint8_t* ReallocateDownward(Allocator* allocator, uint8_t* old_p,
                                     size_t old_size, size_t new_size,
                                     size_t in_use_back, size_t in_use_front) {
 -  return allocator ? allocator->reallocate_downward(old_p, old_size, new_size,
@@ -53,12 +53,12 @@ index d4724122..975d9380 100644
  
  }  // namespace flatbuffers
 diff --git a/include/flatbuffers/flexbuffers.h 
b/include/flatbuffers/flexbuffers.h
-index 8e8cac14..52dae316 100644
+index 2784daf..a82fabd 100644
 --- a/include/flatbuffers/flexbuffers.h
 +++ b/include/flatbuffers/flexbuffers.h
-@@ -495,9 +495,24 @@ class Reference {
-           return static_cast<double>(ReadUInt64(Indirect(), byte_width_));
-         case FBT_NULL: return 0.0;
+@@ -542,9 +542,24 @@ class Reference {
+         case FBT_NULL:
+           return 0.0;
          case FBT_STRING: {
 +#if 1
 +#if !defined( _MSC_VER)
@@ -79,10 +79,10 @@ index 8e8cac14..52dae316 100644
            return d;
 +#endif
          }
-         case FBT_VECTOR: return static_cast<double>(AsVector().size());
-         case FBT_BOOL:
+         case FBT_VECTOR:
+           return static_cast<double>(AsVector().size());
 diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
-index 1ccf3517..34a75193 100644
+index 0313e74..607b6a3 100644
 --- a/include/flatbuffers/util.h
 +++ b/include/flatbuffers/util.h
 @@ -23,6 +23,12 @@
@@ -96,5 +96,5 @@ index 1ccf3517..34a75193 100644
 +#endif
 +
  #ifndef FLATBUFFERS_PREFER_PRINTF
- #  include <iomanip>
- #  include <sstream>
+ #include <iomanip>
+ #include <sstream>

Reply via email to