mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-11-27 18:11:21 +00:00
Merge d3ab94e73a into a75dc9be51
This commit is contained in:
commit
0823d1b6b6
|
|
@ -491,20 +491,50 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ensure_backend(instance, encoding, wasi_nn_ctx);
|
if (encoding == autodetect) {
|
||||||
if (res != success)
|
for (graph_encoding e = openvino; e <= unknown_backend; e++) {
|
||||||
goto fail;
|
if (wasi_nn_ctx->is_backend_ctx_initialized) {
|
||||||
|
call_wasi_nn_func(wasi_nn_ctx->backend, deinit, res,
|
||||||
|
wasi_nn_ctx->backend_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
call_wasi_nn_func(wasi_nn_ctx->backend, load, res, wasi_nn_ctx->backend_ctx,
|
res = ensure_backend(instance, e, wasi_nn_ctx);
|
||||||
&builder_native, encoding, target, g);
|
if (res != success) {
|
||||||
if (res != success)
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
goto fail;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
call_wasi_nn_func(wasi_nn_ctx->backend, load, res,
|
||||||
|
wasi_nn_ctx->backend_ctx, &builder_native, e,
|
||||||
|
target, g);
|
||||||
|
if (res != success) {
|
||||||
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res = ensure_backend(instance, encoding, wasi_nn_ctx);
|
||||||
|
if (res != success)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
call_wasi_nn_func(wasi_nn_ctx->backend, load, res,
|
||||||
|
wasi_nn_ctx->backend_ctx, &builder_native, encoding,
|
||||||
|
target, g);
|
||||||
|
if (res != success)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
// XXX: Free intermediate structure pointers
|
// XXX: Free intermediate structure pointers
|
||||||
if (builder_native.buf)
|
if (builder_native.buf) {
|
||||||
wasm_runtime_free(builder_native.buf);
|
wasm_runtime_free(builder_native.buf);
|
||||||
unlock_ctx(wasi_nn_ctx);
|
}
|
||||||
|
if (wasi_nn_ctx) {
|
||||||
|
unlock_ctx(wasi_nn_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -565,17 +595,29 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ensure_backend(instance, autodetect, wasi_nn_ctx);
|
for (graph_encoding e = openvino; e <= unknown_backend; e++) {
|
||||||
if (res != success)
|
if (wasi_nn_ctx->is_backend_ctx_initialized) {
|
||||||
goto fail;
|
call_wasi_nn_func(wasi_nn_ctx->backend, deinit, res,
|
||||||
|
wasi_nn_ctx->backend_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
|
res = ensure_backend(instance, e, wasi_nn_ctx);
|
||||||
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
|
if (res != success) {
|
||||||
g);
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
if (res != success)
|
continue;
|
||||||
goto fail;
|
}
|
||||||
|
|
||||||
|
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
|
||||||
|
wasi_nn_ctx->backend_ctx, nul_terminated_name,
|
||||||
|
name_len, g);
|
||||||
|
if (res != success) {
|
||||||
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
res = success;
|
|
||||||
fail:
|
fail:
|
||||||
if (nul_terminated_name != NULL) {
|
if (nul_terminated_name != NULL) {
|
||||||
wasm_runtime_free(nul_terminated_name);
|
wasm_runtime_free(nul_terminated_name);
|
||||||
|
|
@ -627,18 +669,29 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ensure_backend(instance, autodetect, wasi_nn_ctx);
|
for (graph_encoding e = openvino; e <= unknown_backend; e++) {
|
||||||
if (res != success)
|
if (wasi_nn_ctx->is_backend_ctx_initialized) {
|
||||||
goto fail;
|
call_wasi_nn_func(wasi_nn_ctx->backend, deinit, res,
|
||||||
;
|
wasi_nn_ctx->backend_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res,
|
res = ensure_backend(instance, e, wasi_nn_ctx);
|
||||||
wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
|
if (res != success) {
|
||||||
nul_terminated_config, config_len, g);
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
if (res != success)
|
continue;
|
||||||
goto fail;
|
}
|
||||||
|
|
||||||
|
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res,
|
||||||
|
wasi_nn_ctx->backend_ctx, nul_terminated_name,
|
||||||
|
name_len, nul_terminated_config, config_len, g);
|
||||||
|
if (res != success) {
|
||||||
|
NN_ERR_PRINTF("continue trying the next");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
res = success;
|
|
||||||
fail:
|
fail:
|
||||||
if (nul_terminated_name != NULL) {
|
if (nul_terminated_name != NULL) {
|
||||||
wasm_runtime_free(nul_terminated_name);
|
wasm_runtime_free(nul_terminated_name);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user