@@ -49,17 +49,21 @@ namespace Eloquent {
4949 failed (false ) {
5050 }
5151
52+ ~TfLite () {
53+ delete reporter;
54+ delete interpreter;
55+ }
56+
5257 /* *
5358 * Inizialize NN
5459 *
5560 * @param modelData
5661 * @return
5762 */
5863 bool begin (const unsigned char *modelData) {
59- static tflite::MicroErrorReporter microReporter ;
60- static tflite::ops::micro::AllOpsResolver resolver ;
64+ tflite::ops::micro::AllOpsResolver resolver ;
65+ reporter = new tflite::MicroErrorReporter () ;
6166
62- reporter = µReporter;
6367 model = tflite::GetModel (modelData);
6468
6569 // assert model version and runtime version match
@@ -75,21 +79,19 @@ namespace Eloquent {
7579 return false ;
7680 }
7781
78- static tflite::MicroInterpreter interpreter (model, resolver, tensorArena, tensorArenaSize, reporter);
82+ interpreter = new tflite::MicroInterpreter (model, resolver, tensorArena, tensorArenaSize, reporter);
7983
80- if (interpreter. AllocateTensors () != kTfLiteOk ) {
84+ if (interpreter-> AllocateTensors () != kTfLiteOk ) {
8185 failed = true ;
8286 error = CANNOT_ALLOCATE_TENSORS;
8387
8488 return false ;
8589 }
8690
87- input = interpreter. input (0 );
88- output = interpreter. output (0 );
91+ input = interpreter-> input (0 );
92+ output = interpreter-> output (0 );
8993 error = OK;
9094
91- this ->interpreter = &interpreter;
92-
9395 return true ;
9496 }
9597
@@ -192,6 +194,14 @@ namespace Eloquent {
192194 return classIdx;
193195 }
194196
197+ /* *
198+ * Get error
199+ * @return
200+ */
201+ TfLiteError getError () {
202+ return error;
203+ }
204+
195205 /* *
196206 * Get error message
197207 * @return
0 commit comments