mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 08:48:33 +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/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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
typedef uint32_t buffer_size;
|
||||
|
||||
typedef enum {
|
||||
suces = 0,
|
||||
success = 0,
|
||||
invalid_argument,
|
||||
missing_memory,
|
||||
busy
|
||||
|
|
Loading…
Reference in New Issue
Block a user