feat: "load module done"

This commit is contained in:
Ahmedounet 2022-06-13 16:32:11 +02:00
parent 521e281ead
commit 4763c710a5
3 changed files with 32 additions and 14 deletions

View File

@ -4,20 +4,38 @@
#include <tensorflow/lite/kernels/register.h>
#include <tensorflow/lite/model.h>
#include <tensorflow/lite/optional_debug_tools.h>
#include <tensorflow/lite/error_reporter.h>
enum Idx {GRAPH=0, GRAPH_SIZE=1 };
std::unique_ptr<tflite::Interpreter> interpreter = NULL;
std::unique_ptr<tflite::FlatBufferModel> model = NULL;
uint32_t _load(graph_builder_array builder, graph_encoding encoding) {
uint32_t *size = (uint32_t*) builder[1];
printf("inside _load: %d\n", *size);
return suces;
// tflite::ErrorReporter *error_reporter;
// model = tflite::FlatBufferModel::BuildFromBuffer(
// (const char *)builder[0],
// 1000, // TODO: find how to pass buffer size
// error_reporter
// );
// tflite::ops::builtin::BuiltinOpResolver resolver;
// tflite::InterpreterBuilder(*model, resolver)(&interpreter);
uint32_t _load(graph_builder_array graph_builder, graph_encoding encoding) {
if(encoding!=tensorflow){return invalid_argument;}
uint32_t *size = (uint32_t*) graph_builder[Idx::GRAPH_SIZE];
tflite::ErrorReporter *error_reporter;
model = tflite::FlatBufferModel::BuildFromBuffer((const char *)graph_builder[Idx::GRAPH], *size, error_reporter);
if(model== nullptr){
printf("failure: null model \n");
return invalid_argument;
}
// Build the interpreter with the InterpreterBuilder.
tflite::ops::builtin::BuiltinOpResolver resolver;
tflite::InterpreterBuilder builder(*model, resolver);
builder(&interpreter);
if(interpreter==nullptr){
printf("failure: null interpreter \n");
return invalid_argument;
}
return success;
}

View File

@ -9,7 +9,7 @@
extern "C" {
#endif
uint32_t _load(graph_builder_array builder, graph_encoding encoding);
uint32_t _load(graph_builder_array graph_builder, graph_encoding encoding);
#ifdef __cplusplus
}

View File

@ -11,7 +11,7 @@
typedef uint32_t buffer_size;
typedef enum {
suces = 0,
success = 0,
invalid_argument,
missing_memory,
busy