WebNN-native is a native implementation of the Web Neural Network API.
It provides several building blocks:
- WebNN C/C++ headers that applications and other building blocks use.
webnn.hthat is an one-to-one mapping with the WebNN IDL.
- A C++ wrapper for the
- Backend implementations that use platforms’ ML APIs:
- DirectML on Windows 10
- OpenVINO on Windows 10 and Linux
- oneDNN on Windows 10 and Linux
- XNNPACK on Windows 10 and Linux
- Other backends are to be added
WebNN-native uses the code of other open source projects:
- The code generator and infrastructure code of Dawn project.
- The DirectMLX and device wrapper of DirectML project.
- The XNNPACK
Build and Run
WebNN-native uses the Chromium build system and dependency management so you need to install depot_tools and add it to the PATH.
- On Windows, you’ll need to set the environment variable
DEPOT_TOOLS_WIN_TOOLCHAIN=0. This tells depot_tools to use your locally installed version of Visual Studio (by default, depot_tools will try to download a Google-internal version).
Get the code
Get the source code as follows:
# Clone the repo as "webnn-native" > git clone https://github.com/webmachinelearning/webnn-native.git webnn-native && cd webnn-native # Bootstrap the gclient configuration > cp scripts/standalone.gclient .gclient # Fetch external dependencies and toolchains with gclient > gclient sync
Setting up the build
Generate build files using
gn args out/Debug or
gn args out/Release.
A text editor will appear asking build options, the most common option is
gn args out/Release --list shows all the possible options.
To build with DirectML backend, set build option
To build with OpenVINO backend, set build option
To build with oneDNN backend, set build option
To build with XNNPACK backend, set build option
ninja -C out/Release or
ninja -C out/Debug to build WebNN-native.
- To build with XNNPACK backend, please build XNNPACK first, e.g. by
Run unit tests, for example
Run end2end tests, for example
- For OpenVINO backend, please install 2021.2 version and set the environment variables before running the end2end tests.
- For oneDNN backend on Linux, please set the
LD_LIBRARY_PATHenvironment variable to the out folder before running the end2end tests, e.g.
Apache 2.0 Public License.