wasm-micro-runtime/core/iwasm/libraries/wasi-nn/src
YAMAMOTO Takashi ea408ab6c0
wasi-nn: add minimum serialization on WASINNContext (#4387)
currently this is not necessary because context (WASINNContext) is
local to instance. (wasm_module_instance_t)

i plan to make a context shared among instances in a cluster when
fixing https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313.
this is a preparation for that direction.

an obvious alternative is to tweak the module instance context APIs
to allow declaring some kind of contexts instance-local. but i feel,
in this particular case, it's more natural to make "wasi-nn handles"
shared among threads within a "process".

note that, spec-wise, how wasi-nn behaves wrt threads is not defined
at all because wasi officially doesn't have threads yet. i suppose, at
this point, that how wasi-nn interacts with wasi-threads is something
we need to define by ourselves, especially when we are using an outdated
wasi-nn version.

with this change, if a thread attempts to access a context while
another thread is using it, we simply make the operation fail with
the "busy" error. this is intended for the mimimum serialization to
avoid problems like crashes/leaks/etc. this is not intended to allow
parallelism or such.

no functional changes are intended at this point yet.

cf.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2430
2025-06-20 09:48:55 +08:00
..
utils [wasi-nn] Add a new wasi-nn backend openvino (#3603) 2024-07-22 17:16:41 +08:00
wasi_nn_llamacpp.c fix: correct typos and improve comments across multiple files by codespell (#4116) 2025-03-07 08:21:54 +08:00
wasi_nn_openvino.c wasi_nn_openvino.c: remove pre/postprocessing and layout assumptions (#4361) 2025-06-17 13:01:46 +08:00
wasi_nn_openvino.h wasi-nn: Apply new architecture (#3692) 2024-08-13 09:14:52 +08:00
wasi_nn_private.h wasi-nn: add minimum serialization on WASINNContext (#4387) 2025-06-20 09:48:55 +08:00
wasi_nn_tensorflowlite.cpp wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388) 2025-06-18 19:08:57 +08:00
wasi_nn_tensorflowlite.hpp wasi-nn: Apply new architecture (#3692) 2024-08-13 09:14:52 +08:00
wasi_nn.c wasi-nn: add minimum serialization on WASINNContext (#4387) 2025-06-20 09:48:55 +08:00