Skip to content

Add WebNN-native binding for Node.js to expose WebNN JavaScript API#11

Merged
huningxin merged 4 commits intowebmachinelearning:mainfrom
fujunwei:w3c/node
Jun 25, 2021
Merged

Add WebNN-native binding for Node.js to expose WebNN JavaScript API#11
huningxin merged 4 commits intowebmachinelearning:mainfrom
fujunwei:w3c/node

Conversation

@fujunwei
Copy link
Collaborator

webnn-polyfill has 600 test cases to test APIs, ops and models. To avoid porting of these tests to C++, it would be useful to run these JS tests with node.js. The WebNN-native binding is to bind WebNN-native C++ API with addon.

This PR depends on #10.

@BruceDai
Copy link
Collaborator

Thanks much @fujunwei!

Current webnn-polyfill@5c5e9f6 has 615 test cases (614 passing / 1 pending by WebNN Polyfill API):

  • API tests total: 84, passing 84
  • Ops tests total: 266, passing 266
  • Models tests total: 15, passing 14, 1 pending
  • CTS tests total: 250, passing 250

Following node/README.md, I verified this PR:

  1. built webnn-native by DML backend, when executing npm test command to run all tests of webnn-polyfill,
    got 386 passing / 1 pending / 228 failing
  2. built webnn-native by OpenVINO backend, when executing npm test command to run all tests of webnn-polyfill,
    got 385 passing / 1 pending / 229 failing

Let's look at pass status of running Ops tests and Model tests:

Backend Ops tests (npm run test-ops) Model tests (npm run test-models)
DML 128 passing 138* failing 14 passing 1pending
OpenVINO 126 passing 140* failing 14 passing 1 pending

Above '14 passing 1 pending' of running Model tests are same as test result by WebNN polyfill API.
And 138 failing ops tests by DML backend and 140 failing ops tests by OpenVINO backend are most with unimplemented op features likes conv2d support transpose option, and those unimplemented ops (div/exp/gru/instance_norm/max/min/pad/pow/reduce/resample/sigmoid/slice/split/squeeze/sub/tanh/transpose) by WebNN native.

WebNN polyfill Supported ops WebNN native Supported status
add YES
batch_norm YES
clamp YES
concat YES
conv2d YES
div NO
exp NO
gemm YES
gru NO
instance_norm NO
leaky_relu YES
matmul YES
max NO
min NO
mul YES
pad NO
pool2d YES
pow NO
reduce NO
relu YES
resample NO
reshape YES
sigmoid NO
slice NO
softmax YES
split NO
squeeze NO
sub NO
tanh NO
transpose NO

Test logs:

  1. test_log_by_webnn_nodejs_binding_with_dml.txt
  2. test_log_by_webnn_nodejs_binding_with_openvino.txt

@fujunwei fujunwei force-pushed the w3c/node branch 2 times, most recently from 03c6f68 to dbede5b Compare June 17, 2021 05:46
Copy link
Collaborator

@huningxin huningxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks @fujunwei . I left some comments, please take a look.

@fujunwei
Copy link
Collaborator Author

@huningxin Done, thanks.

Copy link
Collaborator

@huningxin huningxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR. It looks good to me.

@huningxin
Copy link
Collaborator

Based on the feedback from WebML WG Teleconference – 24 June 2021, both the webnn-polyfill tests and webnn-native implementation on native ML APIs are useful to inform the spec development. This PR specifically enables running the webnn-polyfill tests on native ML API implementation. With that, I am going to merge this PR and unlock the development of other features, like new API change and ops.

Thanks much @fujunwei and @BruceDai !

@huningxin huningxin merged commit a0aa73d into webmachinelearning:main Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants