mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 16:58:34 +00:00
feat: "load module done"
This commit is contained in:
parent
521e281ead
commit
4763c710a5
|
@ -4,20 +4,38 @@
|
||||||
#include <tensorflow/lite/kernels/register.h>
|
#include <tensorflow/lite/kernels/register.h>
|
||||||
#include <tensorflow/lite/model.h>
|
#include <tensorflow/lite/model.h>
|
||||||
#include <tensorflow/lite/optional_debug_tools.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::Interpreter> interpreter = NULL;
|
||||||
std::unique_ptr<tflite::FlatBufferModel> model = NULL;
|
std::unique_ptr<tflite::FlatBufferModel> model = NULL;
|
||||||
|
|
||||||
uint32_t _load(graph_builder_array builder, graph_encoding encoding) {
|
uint32_t _load(graph_builder_array graph_builder, graph_encoding encoding) {
|
||||||
uint32_t *size = (uint32_t*) builder[1];
|
|
||||||
printf("inside _load: %d\n", *size);
|
if(encoding!=tensorflow){return invalid_argument;}
|
||||||
return suces;
|
|
||||||
// tflite::ErrorReporter *error_reporter;
|
uint32_t *size = (uint32_t*) graph_builder[Idx::GRAPH_SIZE];
|
||||||
// model = tflite::FlatBufferModel::BuildFromBuffer(
|
|
||||||
// (const char *)builder[0],
|
tflite::ErrorReporter *error_reporter;
|
||||||
// 1000, // TODO: find how to pass buffer size
|
|
||||||
// error_reporter
|
model = tflite::FlatBufferModel::BuildFromBuffer((const char *)graph_builder[Idx::GRAPH], *size, error_reporter);
|
||||||
// );
|
|
||||||
// tflite::ops::builtin::BuiltinOpResolver resolver;
|
if(model== nullptr){
|
||||||
// tflite::InterpreterBuilder(*model, resolver)(&interpreter);
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t _load(graph_builder_array builder, graph_encoding encoding);
|
uint32_t _load(graph_builder_array graph_builder, graph_encoding encoding);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
typedef uint32_t buffer_size;
|
typedef uint32_t buffer_size;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
suces = 0,
|
success = 0,
|
||||||
invalid_argument,
|
invalid_argument,
|
||||||
missing_memory,
|
missing_memory,
|
||||||
busy
|
busy
|
||||||
|
|
Loading…
Reference in New Issue
Block a user