feat: partial witx api of build and load

This commit is contained in:
Ahmedounet 2022-06-10 18:22:02 +02:00
parent 55d5bf4293
commit 45a2de831b
2 changed files with 96 additions and 1 deletions

View File

@ -1,3 +1,5 @@
#include "wasi_nn.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -8,6 +10,74 @@
#include <tensorflow/lite/model.h> #include <tensorflow/lite/model.h>
#include <tensorflow/lite/optional_debug_tools.h> #include <tensorflow/lite/optional_debug_tools.h>
void func() { std::unique_ptr<tflite::Interpreter> interpreter = NULL;
std::unique_ptr<tflite::FlatBufferModel> model =NULL;
//Load model functions
int main()
{
char* f=read_file("ssd_tflite");
uint8_t *builder = (uint8_t*) f;
uint8_t *builder_array[1] = { builder };
load(builder_array, 1);
load(model builder, graph_encoding encoding)
}
void load(graph_builder_array builder, graph_encoding encoding)
{
model = tflite::FlatBufferModel::BuildFromBuffer(builder[0]);
tflite::ops::builtin::BuiltinOpResolver resolver;
tflite::InterpreterBuilder builder(*model, resolver);
builder(&interpreter);
} }
void init_execution_context()
{
}
//run inference functions
void set_input()
{
interpreter->AllocateTensors() ;
}
void compute (graph_execution_context context )
{
return
}
void get_output()
{
}
/*
static NativeSymbol native_symbols_wasi_nn[] = {
REG_NATIVE_FUNC(args_get, "(**)i"),
REG_NATIVE_FUNC(args_sizes_get, "(**)i"),
REG_NATIVE_FUNC(clock_res_get, "(i*)i"),
REG_NATIVE_FUNC(clock_time_get, "(iI*)i"),
REG_NATIVE_FUNC(environ_get, "(**)i"),
REG_NATIVE_FUNC(environ_sizes_get, "(**)i"),
};
*/
uint32
get_wasi_nn_export_apis(NativeSymbol **p_libc_wasi_apis)
{
*p_libc_wasi_apis = native_symbols_libc_wasi;
return sizeof(native_symbols_libc_wasi) / sizeof(NativeSymbol);
}

View File

@ -9,3 +9,28 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
typedef uint32_t buffer_size;
typedef enum:uint16_t {sucess, invalid_argument, missing_memory, busy } nn_erno;
typedef uint32_t * tensor_dimensions;
typedef enum:uint8_t {f16, f32, u8, i32};
typedef struct {
tensor_dimensions dimensions;
tensor_type type;
tensor_data data;
} tensor ;
typedef uint8_t * graph_builder;
typedef graph_builder * graph_builder_array;
typedef handle graph;
typedef enum {openvino=0, tensorflow,onnx } graph_encoding;