|
|
@@ -12,6 +12,31 @@
|
|
|
|
|
|
static const char *TAG = "TFLITE";
|
|
|
|
|
|
+/// Static Resolver muss mit allen Operatoren geladen Werden, die benöägit werden - ABER nur 1x --> gesonderte Funktion /////////////////////////////
|
|
|
+static bool MakeStaticResolverDone = false;
|
|
|
+static tflite::MicroMutableOpResolver<15> resolver;
|
|
|
+
|
|
|
+void MakeStaticResolver()
|
|
|
+{
|
|
|
+ if (MakeStaticResolverDone)
|
|
|
+ return;
|
|
|
+
|
|
|
+ MakeStaticResolverDone = true;
|
|
|
+
|
|
|
+ resolver.AddFullyConnected();
|
|
|
+ resolver.AddReshape();
|
|
|
+ resolver.AddSoftmax();
|
|
|
+ resolver.AddConv2D();
|
|
|
+ resolver.AddMaxPool2D();
|
|
|
+ resolver.AddQuantize();
|
|
|
+ resolver.AddMul();
|
|
|
+ resolver.AddAdd();
|
|
|
+ resolver.AddLeakyRelu();
|
|
|
+ resolver.AddDequantize();
|
|
|
+}
|
|
|
+////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+
|
|
|
float CTfLiteClass::GetOutputValue(int nr)
|
|
|
{
|
|
|
TfLiteTensor* output2 = this->interpreter->output(0);
|
|
|
@@ -179,16 +204,20 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
bool CTfLiteClass::MakeAllocate()
|
|
|
{
|
|
|
- static tflite::AllOpsResolver resolver;
|
|
|
+
|
|
|
+ MakeStaticResolver();
|
|
|
+
|
|
|
|
|
|
#ifdef DEBUG_DETAIL_ON
|
|
|
LogFile.WriteHeapInfo("CTLiteClass::Alloc start");
|
|
|
#endif
|
|
|
|
|
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CTfLiteClass::MakeAllocate");
|
|
|
- this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
|
|
+ this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize);
|
|
|
+// this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
|
|
|
|
|
if (this->interpreter)
|
|
|
{
|
|
|
@@ -285,6 +314,7 @@ bool CTfLiteClass::ReadFileToModel(std::string _fn)
|
|
|
bool CTfLiteClass::LoadModel(std::string _fn)
|
|
|
{
|
|
|
#ifdef SUPRESS_TFLITE_ERRORS
|
|
|
+// this->error_reporter = new tflite::ErrorReporter;
|
|
|
this->error_reporter = new tflite::OwnMicroErrorReporter;
|
|
|
#else
|
|
|
this->error_reporter = new tflite::MicroErrorReporter;
|
|
|
@@ -320,16 +350,21 @@ CTfLiteClass::CTfLiteClass()
|
|
|
CTfLiteClass::~CTfLiteClass()
|
|
|
{
|
|
|
delete this->interpreter;
|
|
|
- delete this->error_reporter;
|
|
|
+// delete this->error_reporter;
|
|
|
|
|
|
psram_free_shared_tensor_arena_and_model_memory();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+#ifdef SUPRESS_TFLITE_ERRORS
|
|
|
namespace tflite
|
|
|
{
|
|
|
+//tflite::ErrorReporter
|
|
|
+// int OwnMicroErrorReporter::Report(const char* format, va_list args)
|
|
|
+
|
|
|
int OwnMicroErrorReporter::Report(const char* format, va_list args)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|