Fix compilation warnings of wasi-nn (#3497)
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
#include "wasi_nn_app_native.h"
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
graph_builder_app_native(wasm_module_inst_t instance,
|
||||
graph_builder_wasm *builder_wasm,
|
||||
graph_builder *builder)
|
||||
@ -27,12 +27,12 @@ graph_builder_app_native(wasm_module_inst_t instance,
|
||||
* builder_array_wasm is consisted of {builder_wasm, size}
|
||||
*/
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
error
|
||||
wasi_nn_error
|
||||
graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
graph_builder_wasm *builder_wasm, uint32_t size,
|
||||
graph_builder_array *builder_array)
|
||||
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
|
||||
error
|
||||
wasi_nn_error
|
||||
graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
graph_builder_array_wasm *builder_array_wasm,
|
||||
graph_builder_array *builder_array)
|
||||
@ -79,7 +79,7 @@ graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
return missing_memory;
|
||||
|
||||
for (uint32_t i = 0; i < array_size; ++i) {
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success
|
||||
!= (res = graph_builder_app_native(instance, &builder_wasm[i],
|
||||
&builder[i]))) {
|
||||
@ -97,7 +97,7 @@ graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
#undef array_size
|
||||
}
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements,
|
||||
tensor_wasm *input_tensor_wasm, tensor_data *data)
|
||||
{
|
||||
@ -119,7 +119,7 @@ tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements,
|
||||
#undef data_size
|
||||
}
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
tensor_dimensions_app_native(wasm_module_inst_t instance,
|
||||
tensor_wasm *input_tensor_wasm,
|
||||
tensor_dimensions **dimensions)
|
||||
@ -159,7 +159,7 @@ tensor_dimensions_app_native(wasm_module_inst_t instance,
|
||||
return success;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensor_app_native(wasm_module_inst_t instance, tensor_wasm *input_tensor_wasm,
|
||||
tensor *input_tensor)
|
||||
{
|
||||
@ -170,7 +170,7 @@ tensor_app_native(wasm_module_inst_t instance, tensor_wasm *input_tensor_wasm,
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
|
||||
tensor_dimensions *dimensions = NULL;
|
||||
if (success
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wasi_nn.h"
|
||||
#include "wasi_nn_types.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "bh_platform.h"
|
||||
@ -47,18 +47,18 @@ typedef struct {
|
||||
} tensor_wasm;
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
error
|
||||
wasi_nn_error
|
||||
graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
graph_builder_wasm *builder_wasm, uint32_t size,
|
||||
graph_builder_array *builder_array);
|
||||
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
|
||||
error
|
||||
wasi_nn_error
|
||||
graph_builder_array_app_native(wasm_module_inst_t instance,
|
||||
graph_builder_array_wasm *builder,
|
||||
graph_builder_array *builder_native);
|
||||
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensor_app_native(wasm_module_inst_t instance, tensor_wasm *input_tensor,
|
||||
tensor *input_tensor_native);
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "wasi_nn.h"
|
||||
#include "wasi_nn_private.h"
|
||||
#include "wasi_nn_app_native.h"
|
||||
#include "wasi_nn_tensorflowlite.hpp"
|
||||
@ -24,14 +23,15 @@
|
||||
|
||||
/* Definition of 'wasi_nn.h' structs in WASM app format (using offset) */
|
||||
|
||||
typedef error (*LOAD)(void *, graph_builder_array *, graph_encoding,
|
||||
execution_target, graph *);
|
||||
typedef error (*INIT_EXECUTION_CONTEXT)(void *, graph,
|
||||
graph_execution_context *);
|
||||
typedef error (*SET_INPUT)(void *, graph_execution_context, uint32_t, tensor *);
|
||||
typedef error (*COMPUTE)(void *, graph_execution_context);
|
||||
typedef error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t,
|
||||
tensor_data, uint32_t *);
|
||||
typedef wasi_nn_error (*LOAD)(void *, graph_builder_array *, graph_encoding,
|
||||
execution_target, graph *);
|
||||
typedef wasi_nn_error (*INIT_EXECUTION_CONTEXT)(void *, graph,
|
||||
graph_execution_context *);
|
||||
typedef wasi_nn_error (*SET_INPUT)(void *, graph_execution_context, uint32_t,
|
||||
tensor *);
|
||||
typedef wasi_nn_error (*COMPUTE)(void *, graph_execution_context);
|
||||
typedef wasi_nn_error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t,
|
||||
tensor_data, uint32_t *);
|
||||
|
||||
typedef struct {
|
||||
LOAD load;
|
||||
@ -177,7 +177,7 @@ is_encoding_implemented(graph_encoding encoding)
|
||||
&& lookup[encoding].get_output;
|
||||
}
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
is_model_initialized(WASINNContext *wasi_nn_ctx)
|
||||
{
|
||||
if (!wasi_nn_ctx->is_model_loaded) {
|
||||
@ -190,12 +190,12 @@ is_model_initialized(WASINNContext *wasi_nn_ctx)
|
||||
/* WASI-NN implementation */
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_wasm *builder,
|
||||
uint32_t builder_wasm_size, graph_encoding encoding,
|
||||
execution_target target, graph *g)
|
||||
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
|
||||
graph_encoding encoding, execution_target target, graph *g)
|
||||
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */
|
||||
@ -211,7 +211,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
|
||||
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
|
||||
bh_assert(instance);
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
graph_builder_array builder_native = { 0 };
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
if (success
|
||||
@ -249,7 +249,7 @@ fail:
|
||||
return res;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
|
||||
graph_execution_context *ctx)
|
||||
{
|
||||
@ -259,7 +259,7 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
|
||||
bh_assert(instance);
|
||||
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_model_initialized(wasi_nn_ctx)))
|
||||
return res;
|
||||
|
||||
@ -278,7 +278,7 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
|
||||
return res;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
uint32_t index, tensor_wasm *input_tensor)
|
||||
{
|
||||
@ -289,7 +289,7 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
bh_assert(instance);
|
||||
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_model_initialized(wasi_nn_ctx)))
|
||||
return res;
|
||||
|
||||
@ -310,7 +310,7 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
return res;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
|
||||
{
|
||||
NN_DBG_PRINTF("Running wasi_nn_compute [ctx=%d]...", ctx);
|
||||
@ -319,7 +319,7 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
|
||||
bh_assert(instance);
|
||||
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_model_initialized(wasi_nn_ctx)))
|
||||
return res;
|
||||
|
||||
@ -330,12 +330,12 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
uint32_t index, tensor_data output_tensor,
|
||||
uint32_t output_tensor_len, uint32_t *output_tensor_size)
|
||||
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
|
||||
error
|
||||
wasi_nn_error
|
||||
wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
uint32_t index, tensor_data output_tensor,
|
||||
uint32_t *output_tensor_size)
|
||||
@ -348,7 +348,7 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
|
||||
bh_assert(instance);
|
||||
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_model_initialized(wasi_nn_ctx)))
|
||||
return res;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "wasi_nn.h"
|
||||
#include "wasi_nn_types.h"
|
||||
#include "wasi_nn_tensorflowlite.hpp"
|
||||
#include "logger.h"
|
||||
|
||||
@ -50,7 +50,7 @@ typedef struct {
|
||||
|
||||
/* Utils */
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
initialize_g(TFLiteContext *tfl_ctx, graph *g)
|
||||
{
|
||||
os_mutex_lock(&tfl_ctx->g_lock);
|
||||
@ -63,7 +63,7 @@ initialize_g(TFLiteContext *tfl_ctx, graph *g)
|
||||
os_mutex_unlock(&tfl_ctx->g_lock);
|
||||
return success;
|
||||
}
|
||||
static error
|
||||
static wasi_nn_error
|
||||
initialize_graph_ctx(TFLiteContext *tfl_ctx, graph g,
|
||||
graph_execution_context *ctx)
|
||||
{
|
||||
@ -78,7 +78,7 @@ initialize_graph_ctx(TFLiteContext *tfl_ctx, graph g,
|
||||
return success;
|
||||
}
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
is_valid_graph(TFLiteContext *tfl_ctx, graph g)
|
||||
{
|
||||
if (g >= MAX_GRAPHS_PER_INST) {
|
||||
@ -96,7 +96,7 @@ is_valid_graph(TFLiteContext *tfl_ctx, graph g)
|
||||
return success;
|
||||
}
|
||||
|
||||
static error
|
||||
static wasi_nn_error
|
||||
is_valid_graph_execution_context(TFLiteContext *tfl_ctx,
|
||||
graph_execution_context ctx)
|
||||
{
|
||||
@ -114,7 +114,7 @@ is_valid_graph_execution_context(TFLiteContext *tfl_ctx,
|
||||
|
||||
/* WASI-NN (tensorflow) implementation */
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_load(void *tflite_ctx, graph_builder_array *builder,
|
||||
graph_encoding encoding, execution_target target, graph *g)
|
||||
{
|
||||
@ -135,7 +135,7 @@ tensorflowlite_load(void *tflite_ctx, graph_builder_array *builder,
|
||||
return invalid_argument;
|
||||
}
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = initialize_g(tfl_ctx, g)))
|
||||
return res;
|
||||
|
||||
@ -168,13 +168,13 @@ tensorflowlite_load(void *tflite_ctx, graph_builder_array *builder,
|
||||
return success;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_init_execution_context(void *tflite_ctx, graph g,
|
||||
graph_execution_context *ctx)
|
||||
{
|
||||
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_valid_graph(tfl_ctx, g)))
|
||||
return res;
|
||||
|
||||
@ -257,13 +257,13 @@ tensorflowlite_init_execution_context(void *tflite_ctx, graph g,
|
||||
return success;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_set_input(void *tflite_ctx, graph_execution_context ctx,
|
||||
uint32_t index, tensor *input_tensor)
|
||||
{
|
||||
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
|
||||
return res;
|
||||
|
||||
@ -328,12 +328,12 @@ tensorflowlite_set_input(void *tflite_ctx, graph_execution_context ctx,
|
||||
return success;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_compute(void *tflite_ctx, graph_execution_context ctx)
|
||||
{
|
||||
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
|
||||
return res;
|
||||
|
||||
@ -341,14 +341,14 @@ tensorflowlite_compute(void *tflite_ctx, graph_execution_context ctx)
|
||||
return success;
|
||||
}
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_get_output(void *tflite_ctx, graph_execution_context ctx,
|
||||
uint32_t index, tensor_data output_tensor,
|
||||
uint32_t *output_tensor_size)
|
||||
{
|
||||
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
|
||||
|
||||
error res;
|
||||
wasi_nn_error res;
|
||||
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
|
||||
return res;
|
||||
|
||||
@ -472,6 +472,8 @@ tensorflowlite_destroy(void *tflite_ctx)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
wasm_runtime_free(tfl_ctx->models[i].model_pointer);
|
||||
|
||||
@ -6,28 +6,28 @@
|
||||
#ifndef WASI_NN_TENSORFLOWLITE_HPP
|
||||
#define WASI_NN_TENSORFLOWLITE_HPP
|
||||
|
||||
#include "wasi_nn.h"
|
||||
#include "wasi_nn_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_load(void *tflite_ctx, graph_builder_array *builder,
|
||||
graph_encoding encoding, execution_target target, graph *g);
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_init_execution_context(void *tflite_ctx, graph g,
|
||||
graph_execution_context *ctx);
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_set_input(void *tflite_ctx, graph_execution_context ctx,
|
||||
uint32_t index, tensor *input_tensor);
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_compute(void *tflite_ctx, graph_execution_context ctx);
|
||||
|
||||
error
|
||||
wasi_nn_error
|
||||
tensorflowlite_get_output(void *tflite_ctx, graph_execution_context ctx,
|
||||
uint32_t index, tensor_data output_tensor,
|
||||
uint32_t *output_tensor_size);
|
||||
|
||||
Reference in New Issue
Block a user