0.0.3 • Published 2 years ago

webnn-tflite-delegate v0.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

WebNN Delegate for tfjs-tflite-node

The webnn-tflite-delegate package adds support for Web Neural Network API (WebNN API) to tfjs-tflite-node.

Dependencies

This package takes dependencies on the WebNN API and implementation of WebNN-native. In this package, the WebNN-native uses a specific commit and the backend implementation of WebNN-native uses OpenVINO 2021.4 version.

Installing

Follow the instructions here to install OpenVINO 2021.4 on Linux (x64) or Windows (x64).

After OpenVINO is installed, you can install the webnn-tflite-delegate package with npm i --save webnn-tflite-delegate.

Usage

Register the WebNN delegate while loading a TFLite model in tfjs-tflite-node by adding it to the list of delegates in the TFLite options:

const model = await loadTFLiteModel('./mobilenetv2.tflite', {
  delegates: [new WebNNDelegate({webnnDevice: WebNNDevice.CPU})],
});

Before running model with this package, set following environment variables:

  • On Linux, run ./setupvars.sh to set environment variables for OpenVINO.
  • On Windows, run .\setupvars.bat to set environment variables for OpenVINO and set the path of dependent WebNN native dll libraries (current location is ./cc_lib/win32_x64/) to PATH.