add a set of apis to configure wasi-nn via InstantiationArgs2#4764
add a set of apis to configure wasi-nn via InstantiationArgs2#4764zhanheng1 wants to merge 36 commits intobytecodealliance:mainfrom
Conversation
77794ae to
c73e4aa
Compare
… named WASINNRegistry. Replace malloc/free to wasm_runtime_malloc/_free, replace strdup to bh_strdup.
302f32b to
9d8e31a
Compare
|
|
||
| #if WASM_ENABLE_WASI_NN != 0 || WASM_ENABLE_WASI_EPHEMERAL_NN != 0 | ||
| wasm_runtime_wasi_nn_registry_create(&nn_registry); | ||
| wasi_nn_set_inst_args(inst_args, nn_registry, &wasi_nn_parse_ctx); |
There was a problem hiding this comment.
shouldn't this be done before inst_args is used? ie. before wasm_runtime_instantiate_ex2
There was a problem hiding this comment.
If I recall correctly, we previously discussed this issue.
Since wasm_runtime_malloc() requires wasm_runtime_instantiate_ex2() to initialize the memory first, this logic should either be implemented inside wasm_runtime_instantiate_ex2(), or extracted as a separate function to be called after wasm_runtime_instantiate_ex2().
Originally, the function was placed in the middle of wasm_runtime_instantiate_ex2(), but it was later suggested that extracting it as a standalone function would be better, which is why the current version was adopted.
| #if WASM_ENABLE_WASI_NN != 0 || WASM_ENABLE_WASI_EPHEMERAL_NN != 0 | ||
| wasm_runtime_wasi_nn_registry_create(&nn_registry); | ||
| wasi_nn_set_inst_args(inst_args, nn_registry, &wasi_nn_parse_ctx); | ||
| wasm_runtime_set_wasi_nn_registry(wasm_module_inst, nn_registry); |
There was a problem hiding this comment.
wasm_runtime_set_wasi_nn_registry is not supposed to be used by the embedder, is it?
i suppose the registry is passed via inst_args.
There was a problem hiding this comment.
If I remember correctly, we've also discussed this issue before.
Since inst_args is destroyed immediately in the next line of code, the WASM application cannot actually use it.
The current version stores the registry in a slot within each WASM module's context, allowing the WASM app to retrieve the registry via the module's context.
Therefore, wasm_runtime_set_wasi_nn_registry should be explicitly called in main.c.
…d graph_paths. Add check for some wasm_runtime_malloc() calls.
add a set of apis to configure wasi-nn via InstantiationArgs2: