@@ -66,7 +66,6 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx)
6666 }
6767 NN_DBG_PRINTF ("[WASI NN] DEINIT..." );
6868 NN_DBG_PRINTF ("Freeing wasi-nn" );
69- NN_DBG_PRINTF ("-> is_model_loaded: %d" , wasi_nn_ctx -> is_model_loaded );
7069 NN_DBG_PRINTF ("-> current_encoding: %d" , wasi_nn_ctx -> backend );
7170
7271 bh_assert (!wasi_nn_ctx -> busy );
@@ -202,15 +201,6 @@ wasi_nn_destroy()
202201}
203202
204203/* Utils */
205- static wasi_nn_error
206- is_model_initialized (WASINNContext * wasi_nn_ctx )
207- {
208- if (!wasi_nn_ctx -> is_model_loaded ) {
209- NN_ERR_PRINTF ("Model not initialized." );
210- return runtime_error ;
211- }
212- return success ;
213- }
214204
215205/*
216206 *TODO: choose a proper backend based on
@@ -510,8 +500,6 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
510500 if (res != success )
511501 goto fail ;
512502
513- wasi_nn_ctx -> is_model_loaded = true;
514-
515503fail :
516504 // XXX: Free intermediate structure pointers
517505 if (builder_native .buf )
@@ -587,7 +575,6 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
587575 if (res != success )
588576 goto fail ;
589577
590- wasi_nn_ctx -> is_model_loaded = true;
591578 res = success ;
592579fail :
593580 if (nul_terminated_name != NULL ) {
@@ -651,7 +638,6 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
651638 if (res != success )
652639 goto fail ;
653640
654- wasi_nn_ctx -> is_model_loaded = true;
655641 res = success ;
656642fail :
657643 if (nul_terminated_name != NULL ) {
@@ -684,9 +670,6 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
684670 goto fail ;
685671 }
686672
687- if (success != (res = is_model_initialized (wasi_nn_ctx )))
688- goto fail ;
689-
690673 if (!wasm_runtime_validate_native_addr (
691674 instance , ctx , (uint64 )sizeof (graph_execution_context ))) {
692675 NN_ERR_PRINTF ("ctx is invalid" );
@@ -719,9 +702,6 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
719702 goto fail ;
720703 }
721704
722- if (success != (res = is_model_initialized (wasi_nn_ctx )))
723- goto fail ;
724-
725705 tensor input_tensor_native = { 0 };
726706 if (success
727707 != (res = tensor_app_native (instance , input_tensor ,
@@ -756,9 +736,6 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
756736 goto fail ;
757737 }
758738
759- if (success != (res = is_model_initialized (wasi_nn_ctx )))
760- goto fail ;
761-
762739 call_wasi_nn_func (wasi_nn_ctx -> backend , compute , res ,
763740 wasi_nn_ctx -> backend_ctx , ctx );
764741fail :
@@ -792,9 +769,6 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
792769 goto fail ;
793770 }
794771
795- if (success != (res = is_model_initialized (wasi_nn_ctx )))
796- goto fail ;
797-
798772#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
799773 if (!wasm_runtime_validate_native_addr (instance , output_tensor ,
800774 output_tensor_len )) {
0 commit comments