microsoft / microsoft/onnxruntime

[Build] WASM build of `v1.20.1` with `--use_xnnpack` fails

Open
#23,460 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

build contributions welcome ep:Xnnpack platform:web
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the issue

Hello 👋

I want to utilize the ONNX runtime in a Web application. I successfully built the static library of ONNX runtime with SIMD and threading and linked it within my Emscripten project. The CPU execution providers works great. Now I tried to also include the XNNPACK execution provider with the `--use_xnnpack` flag to improve the performance of the inferencing.

However, the `src/amalgam` directory is missing from the XNNPACK distribution. [`xnnpack.cmake`](https://github.com/microsoft/onnxruntime/blob/ff8465eda45a5ab1259fc5f1091fd38a33b596c4/cmake/external/xnnpack.cmake#L98) says:

> \# See source lists in [_deps/googlexnnpack-src/BUILD.bazel for wasm_prod_microkernels](https://github.com/google/XNNPACK/blob/0da379fc4808f9601faef392352018c741c0f297/BUILD.bazel)

I cannot find any documentation at the XNNPACK how to manually generate these amalgam (?) microkernels. I also cannot find an example in this repository. How to build the XNNPACK execution provider for the Web?

### Urgency

_No response_

### Target platform

WASM

### Build script

```
onnxruntime/build.sh \
--build_dir ./onnxruntime-build \
--config Release \
--build_wasm_static_lib \
--enable_wasm_simd \
--enable_wasm_threads \
--skip_tests \
--disable_wasm_exception_catching \
--disable_rtti \
--use_xnnpack \
--parallel
```

### Error / output

```
CMake Error at external/xnnpack.cmake:189 (target_sources):
Cannot find source file:

./onnxruntime-build/Release/_deps/googlexnnpack-src/src/amalgam/gen/scalar.c

Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
.ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
.f95 .f03 .hip .ispc
Call Stack (most recent call first):
external/onnxruntime_external_deps.cmake:566 (include)
CMakeLists.txt:614 (include)
```

### Visual Studio Version

_No response_

### GCC / Compiler Version

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with build.sh and cmake/external/xnnpack.cmake, especially the source path for src/amalgam/gen/scalar.c. Compare that expectation with XNNPACK's referenced BUILD.bazel wasm_prod_microkernels sources and reproduce the provided WASM build command. Done means the XNNPACK execution provider builds successfully for WASM with --use_xnnpack.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, wasm
Domain
build-system, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.