Commit Graph

1634 Commits

Author SHA1 Message Date
aa53d648fa wasi-nn: fix tensor_data abi for wasi_ephemeral_nn (#4379)
it's "(list u8)" in the witx definition.

the new definition matches both of our own host definition
(struct tensor_wasm) and wasmtime.

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4352
2025-06-19 14:18:36 +08:00
a29f3943ef core/iwasm/libraries/wasi-nn/test: use the correct version of keras (#4383) 2025-06-18 19:24:06 +08:00
db7714f0f5 wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388)
this backend assumes fp32 here and there.
it's safer to reject unexpected inputs explicitly.
2025-06-18 19:08:57 +08:00
4bf799c3af core/iwasm/libraries/wasi-nn/test/build.sh: add a tip for intel mac (#4389)
i keep forgetting this and had to re-investigate it at least twice.
hopefully this can be helpful for others too.
2025-06-18 19:06:57 +08:00
cba9001749 wasi-nn: don't try to deinit uninitialized backend (#4375)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4339
2025-06-17 17:40:53 +08:00
c9b8c16088 wasi_nn_openvino.c: remove pre/postprocessing and layout assumptions (#4361)
as wasi-nn doesn't have these concepts, the best we can do without
risking breaking certain applications here is to pass through tensors
as they are.

this matches wasmtime's behavior.

tested with:

* wasmtime classification-example
  (with this change, this example fails on tensor size mismatch
  instead of implicitly resizing it.)

* license-plate-recognition-barrier-0007, a converted version
  with non-fp32 output. [1]
  (with this change, this model outputs integers as expected.)

[1] cd7ebe313b/models/public/license-plate-recognition-barrier-0007
2025-06-17 13:01:46 +08:00
6dfb410869 send an empty/error reply from server (#4362)
Signed-off-by: Su Yihan <yihan.su@intel.com>
2025-06-17 13:00:58 +08:00
2f0750a6fe wasi_nn_openvino.c: add a missing buffer overflow check in get_output (#4353)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4351
2025-06-17 11:17:00 +08:00
20be1d33fe wasi_ephemeral_nn.h: prefix identfiers to avoid too generic names (#4358) 2025-06-17 11:15:01 +08:00
745da82cd6 wasi_nn_openvino.c: remove broken xml check (#4365)
`xml.buf[xml.size]` check is broken because it accesses past
the end of the buffer.

anyway, openvino doesn't seem to care the NUL termination.
2025-06-17 11:02:36 +08:00
7bbdbf5212 add validation for array type in load_init_expr(GC only) (#4370) 2025-06-17 11:01:38 +08:00
0d001c4c38 wasi-nn: fix backend leak on multiple loads (#4366)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4340
2025-06-17 11:01:07 +08:00
8e60feb181 Collective fix for typos and minor bugs (#4369) 2025-06-17 09:26:00 +08:00
0343aaf8c3 Modify AOT static PGO to conform to llvm-18 and add a CI job to test static PGO on the coremark benchmark (#4345)
* static PGO compatible with llvm18 and add CI job to test static PGO on coremark benchmark
* update comments and warning info, bitmaps section in llvm profdata shouldn't be used in PGO
2025-06-12 16:57:11 +08:00
75bf9797a2 Update type validation in load_table_import() and load_table() (#4296)
Prevent from value type.

https://webassembly.github.io/spec/core/valid/types.html#table-types
https://webassembly.github.io/gc/core/syntax/types.html#reference-types
2025-06-12 15:01:42 +08:00
5478d267f4 wasi_nn_openvino.c: remove the tensor layout adjustment logic (#4308)
the logic in question seems like an attempt to work around
some application bugs.
my wild guess is that it was for classification-example.
cf. https://github.com/bytecodealliance/wasmtime/issues/10867
2025-06-12 09:34:14 +08:00
3a087c4244 wamr-wasi-extensions: add a cmake package to provide our wasi extension (#4344)
* wasi_ephemeral_nn.h: add a convenience wrapper header
* wamr-wasi-extensions: add a cmake package to provide our wasi extension

the sample app was tested with:
* wasmtime
* iwasm with https://github.com/bytecodealliance/wasm-micro-runtime/pull/4308

currently only contains wasi-nn.
maybe it makes sense to add lib-socket things as well.

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4288
2025-06-12 09:33:25 +08:00
928598f1ce add heap-type check for GC when ref.null (#4300)
- According to [Link 1](https://webassembly.github.io/gc/core/valid/instructions.html#xref-syntax-instructions-syntax-instr-ref-mathsf-ref-null-mathit-ht), we must ensure that the heap type is valid when ref.null.
- According to [Link 2](https://webassembly.github.io/gc/core/valid/types.html#heap-types), a heap type is considered valid if it is either a concrete heap type or an abstract heap type.

However, in this function, the check for abstract heap types (absheaptype) was clearly missing, so this condition needs to be added explicitly in the if statement.

- When GC is disabled, no change is needed.
- When GC is enabled, heap types in WAMR are LEB-encoded values ([Link 3](https://webassembly.github.io/gc/core/appendix/index-types.html)). Therefore, we must use read_leb_int32 to parse the heap type correctly. And we can compute the original type1 using type1 = (uint8)((int32)0x80 + heap_type);.
2025-06-12 09:31:17 +08:00
c932597057 wasi_nn_types.h: remove a seemingly stale comment (#4348) 2025-06-12 09:29:59 +08:00
c4623e2cb5 Enable aot memory64 sw bounds checks by default (#4350)
- enable aot memory64 sw bounds checks by default
2025-06-12 08:44:45 +08:00
7f968f5926 wasi_socket_ext.c: avoid tls to make this library-friendly (#4338) 2025-06-11 07:46:35 +08:00
ea5757f1d7 wasi-nn: do not assign wasi_nn_ctx->backend multiple times (#4329) 2025-06-09 11:36:31 +08:00
4d6b8dcd5d wasi_nn.h: make this compatible with wasi_ephemeral_nn (#4330)
- wasi_nn.h: make this compatible with wasi_ephemeral_nn
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4323

- fix WASM_ENABLE_WASI_EPHEMERAL_NN build
this structure is used by host logic as well.
ideally definitions for wasm and host should be separated.
until it happens, check __wasm__ to avoid the breakage.
2025-06-09 11:36:05 +08:00
933f8124b0 wasi-nn: fix the size of tensor->type (#4333)
* this enum is (@witx tag u8) in witx
* it seems that some wasm modules actually use non-zero padding
  and cause errors
* it's a bad practice to use C enum for ABI description anyway
2025-06-06 15:08:18 +08:00
769d16eaab wasi-nn: move some host-only things out of wasi_nn_types.h (#4334)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4324
2025-06-06 15:07:29 +08:00
79cb4366ae wasi-nn: remove unused wasi_nn_dump_tensor_dimension prototype (#4325) 2025-06-05 09:48:28 +08:00
b20ebc2724 wasi_nn.h: add import_name attribute (#4328)
this would fix undefined symbol errors by making it clear
these functions are imported.

references:
e2c698c7e8/llvm/lib/MC/WasmObjectWriter.cpp (L1798-L1799)
e2c698c7e8/llvm/lib/Object/WasmObjectFile.cpp (L749-L752)
e2c698c7e8/lld/wasm/Symbols.cpp (L203)
e2c698c7e8/lld/wasm/Relocations.cpp (L36-L40)
2025-06-05 09:48:00 +08:00
85efe08431 wasi-nn: protect the backend lookup table with a lock (#4319)
this would avoid potential issues when multiple instances happen to
make an attempt to load a backend at the same time.

Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4314
2025-06-05 09:19:46 +08:00
93ef19b0ca handle nullable heap reference types in import section (#4302) 2025-06-03 13:28:26 +08:00
6a00874f2f wasi_nn_openvino.c: make this buildable (#4305) 2025-06-03 13:28:13 +08:00
61cb97221e wasi-nn: fix shared library filenames for macOS (#4306)
tested with openvino
2025-06-03 13:23:19 +08:00
ae6e490ad5 fix wasi-nn abi definitions (#4307)
sync with a more appropriate version of the definitions.

as we use the "wasi_ephemeral_nn", which is p1-based, it seems
more appropriate to use definitions from witx, not wit.

it's a bit unfortunate p2-based wasi-nn made gratuitous changes
like this from p1.

note: this is an ABI change.
2025-06-03 13:22:48 +08:00
16c46751ac wasi-nn: remove "backends" argument from detect_and_load_backend() (#4309)
it seems meaningless and quite confusing to access a table with
two aliases ("lookup" and "backends") within a function.

no functional changes are intended.
2025-06-03 13:22:27 +08:00
1c12a32066 wasi_nn_openvino.c: fix a few printf formats (#4310) 2025-06-03 13:21:32 +08:00
938503af38 Bump uvwasi to latest commit #392e1f1 (#4312) 2025-06-03 13:21:17 +08:00
aa1ff778b9 add load_by_name in wasi-nn (#4298) 2025-06-03 06:26:58 +08:00
670aa83985 Bump version to 2.3.1 and update release notes (#4303) 2025-06-02 10:45:50 +08:00
207da7b22f updating WASI stdio handle initialization and build options for UVWASI (#4260) 2025-05-30 07:42:39 +08:00
3ab9f84026 Dockerfile.vx-delegate build error fix (#4273)
- specify tensorflow version & bugfix
2025-05-28 20:29:41 +08:00
7f9e49213e Enhance type checking for function types in loader and improve error handling (#4294)
Especially when GC is enabled, a valid item of `module->types` needs additional
checks before casting to WASMFuncType.

Also, avoid overflowing if reftype_map_count is 0.

Additionally, correctly set IN_OSS_FUZZ based on CFLAGS_ENV for sanitizer
configuration. Update ASan and UBSan messages for clarity in non-oss-fuzz
environments.
2025-05-28 20:29:09 +08:00
21bcf5c75d Fix Compiler Error C2491 (#4286)
> Data, static data members, and functions can be declared as `dllimports` but not defined as `dllimports`.

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2491?view=msvc-170
2025-05-28 09:05:07 +08:00
c018b8ab98 feat: Add instruction metering for interpreter (#4122)
- add instruction metering support with execution limit
- initialize instruction execution limit in exec_env
- docs: add instruction metering section to build_wamr documentation
2025-05-26 16:16:42 +08:00
e48367c044 Fix SIMD load lane to avoid incompatible pointer types (#4278) 2025-05-19 10:31:17 +08:00
c7b2db1832 Update version to 2.3.0 (#4171)
- Update version to 2.3.0
- Update RELEASE_NOTES.md. Remove commits that forget to squash when PRs were merged, and some updates on commit messages

---------

Co-authored-by: James Marsh <mrshnja@amazon.co.uk>
Co-authored-by: liang.he@intel.com <liang.he@intel.com>
Co-authored-by: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com>
2025-05-14 17:32:00 +08:00
28702edaf7 Merge commit from fork 2025-05-14 12:43:55 +08:00
129dc3a30f Add select 128 (#4236)
Add select 128
2025-05-14 12:35:56 +08:00
70b35f9e60 Check for WASM_ENABLE_SIMDE in a couple more places (#4266)
For WAMR users who don't use cmake, it's possible that WASM_ENABLE_SIMD
is set when WASM_ENABLE_SIMDE isn't. This was causing build failures.
2025-05-14 10:58:19 +08:00
f0a8286863 Refactor fast-interpreter SIMD compilation flags (#4261)
- enable SIMD flag by default unless hardware limitation
- use SIMDE flag to control fast-interpreter behavior
2025-05-14 10:38:30 +08:00
26aa4830e9 fix buf checking in load_table_section (#4276)
Signed-off-by: Su Yihan <yihan.su@intel.com>
2025-05-14 06:35:32 +08:00
3cce6fdaac avoid access null pointer (#4262) 2025-05-12 10:21:45 +08:00