Skip to content

add a set of apis to configure wasi-nn via InstantiationArgs2#4764

Open
zhanheng1 wants to merge 26 commits intobytecodealliance:mainfrom
dongsheng28849455:InstantiationArgs2-wasinn
Open

add a set of apis to configure wasi-nn via InstantiationArgs2#4764
zhanheng1 wants to merge 26 commits intobytecodealliance:mainfrom
dongsheng28849455:InstantiationArgs2-wasinn

Conversation

@zhanheng1
Copy link
Contributor

add a set of apis to configure wasi-nn via InstantiationArgs2:

  1. Add a new command line option for wasi-nn: --wasi-nn-graph=encoding:target:model_path1:model_path2:...:model_pathN;
  2. Add new structs to manage this cmd option: WASINNGlobalContext and wasi_nn_graph_registry;
  3. Add 2 new parameters for load_by_name(encoding and target). load_by_name() can get encoding and target from WASINNGlobalContext and set into backend.
  4. Update test codes.

@zhanheng1 zhanheng1 force-pushed the InstantiationArgs2-wasinn branch from 77794ae to c73e4aa Compare December 19, 2025 07:07
@zhanheng1 zhanheng1 marked this pull request as ready for review December 23, 2025 01:52
#include "wasi_nn.h"

#undef WASM_ENABLE_WASI_EPHEMERAL_NN
#undef WASI_NN_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

@zhanheng1 zhanheng1 Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In wasi_ephemeral_nn.h, macros are defined and then wasi_nn.h is included immediately after, but these macro definitions are later undefined (#undef). This means that in utils.h, the macros might be in an undefined state, leading to compilation errors( if WASM_ENABLE_WASI_EPHEMERAL_NN != 0).

"through --wasi-nn-graph",
nul_terminated_name);
res = not_found;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suppose wasi_nn_load_by_name_with_config needs an equivalent.
i guess it's simpler to make them share a common logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants