Skip to content

Commit fc3f009

Browse files
committed
Upgrade TensorFlowLite
1 parent 1464fc0 commit fc3f009

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

src/AudioTools/AudioLibs/TfLiteAudioStream.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Configure FFT to output 16 bit fixed point.
44
#define FIXED_POINT 16
55

6+
//#include <MicroTFLite.h>
67
#include <TensorFlowLite.h>
78
#include <cmath>
89
#include <cstdint>
@@ -13,7 +14,6 @@
1314
#include "tensorflow/lite/experimental/microfrontend/lib/frontend_util.h"
1415
#include "tensorflow/lite/micro/all_ops_resolver.h"
1516
#include "tensorflow/lite/micro/kernels/micro_ops.h"
16-
#include "tensorflow/lite/micro/micro_error_reporter.h"
1717
#include "tensorflow/lite/micro/micro_interpreter.h"
1818
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
1919
#include "tensorflow/lite/micro/system_setup.h"
@@ -55,25 +55,6 @@ class TfLiteWriter {
5555
virtual bool begin(TfLiteAudioStreamBase *parent) = 0;
5656
virtual bool write(const int16_t sample) = 0;
5757
};
58-
/**
59-
* @brief Error Reporter using the Audio Tools Logger
60-
* @ingroup tflite
61-
* @author Phil Schatzmann
62-
* @copyright GPLv3
63-
*/
64-
class TfLiteAudioErrorReporter : public tflite::ErrorReporter {
65-
public:
66-
virtual ~TfLiteAudioErrorReporter() {}
67-
virtual int Report(const char* format, va_list args) override {
68-
int result = snprintf(msg, 200, format, args);
69-
LOGE(msg);
70-
return result;
71-
}
72-
73-
protected:
74-
char msg[200];
75-
} my_error_reporter;
76-
tflite::ErrorReporter* error_reporter = &my_error_reporter;
7758

7859
/**
7960
* @brief Configuration settings for TfLiteAudioStream
@@ -96,7 +77,7 @@ struct TfLiteConfig {
9677
// Create an area of memory to use for input, output, and intermediate arrays.
9778
// The size of this will depend on the model you’re using, and may need to be
9879
// determined by experimentation.
99-
int kTensorArenaSize = 10 * 1024;
80+
size_t kTensorArenaSize = 10 * 1024;
10081

10182
// Keeping these as constant expressions allow us to allocate fixed-sized
10283
// arrays on the stack for our working memory.
@@ -980,14 +961,12 @@ class TfLiteAudioStream : public TfLiteAudioStreamBase {
980961
TRACEI();
981962
if (cfg.useAllOpsResolver) {
982963
tflite::AllOpsResolver resolver;
983-
static tflite::MicroInterpreter static_interpreter(
984-
p_model, resolver, p_tensor_arena, cfg.kTensorArenaSize,
985-
error_reporter);
964+
static tflite::MicroInterpreter static_interpreter{
965+
p_model, resolver, p_tensor_arena, cfg.kTensorArenaSize};
986966
p_interpreter = &static_interpreter;
987967
} else {
988968
// NOLINTNEXTLINE(runtime-global-variables)
989-
static tflite::MicroMutableOpResolver<4> micro_op_resolver(
990-
error_reporter);
969+
static tflite::MicroMutableOpResolver<4> micro_op_resolver{};
991970
if (micro_op_resolver.AddDepthwiseConv2D() != kTfLiteOk) {
992971
return false;
993972
}
@@ -1001,9 +980,8 @@ class TfLiteAudioStream : public TfLiteAudioStreamBase {
1001980
return false;
1002981
}
1003982
// Build an p_interpreter to run the model with.
1004-
static tflite::MicroInterpreter static_interpreter(
1005-
p_model, micro_op_resolver, p_tensor_arena, cfg.kTensorArenaSize,
1006-
error_reporter);
983+
static tflite::MicroInterpreter static_interpreter{
984+
p_model, micro_op_resolver, p_tensor_arena, cfg.kTensorArenaSize};
1007985
p_interpreter = &static_interpreter;
1008986
}
1009987
}

0 commit comments

Comments
 (0)