Skip to content

Commit

Permalink
Add node and build script implementation
Browse files Browse the repository at this point in the history
[Test] Add validation for Model

[Node] Refactor binding.gyp

Merge pull request webmachinelearning#233 from otcshare/mingming/lenet

[LeNet] Add the “-n” option to run the inference n times and print out the mean time

[Node] Ops test can workable on Linux

Merge pull request webmachinelearning#250 from otcshare/junwei/node

[Node] Refactor binding.gyp

[LeNet] fix -n option accepts negative values

fix webmachinelearning#253

Merge pull request webmachinelearning#254 from otcshare/nhu/lenet_perf

[LeNet] fix -n option accepts negative values

[Node] Most ops test can run on Linux and Windows.

[node] Use naming style as Dawn for file name

Merge pull request webmachinelearning#272 from otcshare/lisha/node

[node] Use naming style as Dawn for file name

[base] Add difination of leakyRelu

Merge pull request webmachinelearning#276 from otcshare/lisha/leakyRelu

[base] Add definition of leakyRelu

Merge pull request webmachinelearning#257 from otcshare/junwei/node

[Node] Most ops test can run on Linux and Windows.

[Base] Add Concat operations

[IE] Implement Concat with nGraph

[IE]Implement LeakyRelu op

[test] Added LeakyReluTests.

[build] Prepared .gclient file for gclient sync.

[build] Optimized build function of scripts.

[build] Enabled package function of build scripts.

[build] Enabled upload function of build scripts.

[build] Updated README.md for build scripts.

Merge pull request webmachinelearning#186 from otcshare/df/package-upload-build

[build] Supported to package and upload for build.

[DML] Support Concat operation

[Node] Reuse tests of webnn-polyfill

[build] Enabled notify function of build scripts.

add the asyncworker for compilation

[build] Fixed an issue of rewriting config file.

Merge pull request webmachinelearning#277 from otcshare/df/port_leakyRelu_tests

[test] Added LeakyReluTests.

[DML] Use max dimenssions count

delete friend class CompilationAsyncworker and use std::move to pass value

[build] Removed ienn lib build process.

Merge pull request webmachinelearning#280 from otcshare/junwei/ops

[Base] Add Concat operations

replace references of output_names_ with std::move in ComputeAsyncworker

Merge pull request webmachinelearning#288 from otcshare/kunliang/compilationAsync

add the asyncworker for compilation

[IE] Support depthwise conv2d

Merge pull request webmachinelearning#287 from otcshare/df/build-notify

[build] Enabled notify function of build scripts.

Merge pull request webmachinelearning#278 from otcshare/junwei/dev

[IE] Support depthwise conv2d

[DML] Support LeakyRelu operation

Merge pull request webmachinelearning#302 from otcshare/junwei/ops

[DML] Support LeakyRelu operation

[examples] Print median execution time for LeNet example.
           fixes webmachinelearning#292

[Base] Move common verification to Operand Base

[ie]Add Gemm op

[test]Add GemmTests

[DML] Support Gemm operations

Merge pull request webmachinelearning#304 from otcshare/junwei/ops

[Base] Move common verification to Operand Base

Merge pull request webmachinelearning#299 from otcshare/df/median_value

[examples] Print median value for LeNet example.

[DML] List the operand like a, b, c

Merge pull request webmachinelearning#285 from otcshare/mingming/node

[Node] Reuse tests of webnn-polyfill

Merge pull request webmachinelearning#293 from otcshare/lisha/gemm

[ie]Add Gemm op

[IE] Update ienn binary

[Base] Add definition of Clamp

[IE] Implement Clamp

[End2End] Add end2end tests for Clamp

[Refactor] Refactor some codes

[refactor] Refactor to support undefined options

[DML]Add Clamp

[Refactor] Git cl format and remove some duplicate codes

Merge pull request webmachinelearning#284 from otcshare/mingming/ops

[IE/DML] Implement clamp op

[IE] Define BatchNorm and implement for IE

[IE] Refactor codes for BatchNorm

[test] Added BatchNormWithoutOptions test for batchNormalization op.

[refactor] Refactor to support undefined options

[DML] Implement batchNorm

[DML] Pass BatchNorm test cases

Merge pull request webmachinelearning#301 from otcshare/mingming/batchNorm

[IE/DML] Define BatchNorm and implement for IE

[IE] Update binary on Windows

[Node]Rename to align with Dawn name style

[Node]change code format to align with Dawn

[Node]Fix build fatal

[build_script] Enabled build scripts on execute mode for main branch.

[oneDNN] the initial commit

[oneDNN] implement the constant

[oneDNN] rename files with DNNL postfix

[oneDNN] implement Relu and Softmax

[oneDNN] implement Reshape

[oneDNN] introduce memory reinterprets

[oneDNN] implement transpose

[oneDNN] implement binary add and mul

[oneDNN] implement matmul

[oneDNN] implement conv2d

[oneDNN] implement pool2d

[oneDNN] rename Reorder to ReorderIfNeeded

[oneDNN] use CHECK and ReorderIfNeeded

[oneDNN] fix reshape by reordering to plain layout

[oneDNN] optimize constants reordering

[oneDNN] add download_onednn.py into DEPS

[oneDNN] fix download_onednn.py for Linux

[oneDNN] set the LD_LIBRARY_PATH for Linux

[Base] returning error object for unimplemented ops

To avoid crash for new backend

[Test] assert compilation before use it

To avoid crash for failed test cases

[Node] webnn polyfill can run continuously

[onednn]Fix a typo

[IE]Add support nhwc layout for conv, pool, bn and add filterlayout
definition

[OneDNN]Fix build error caused by spec change

Updated ie_nn_c_api.dll file.

[tools] Implemented nightly auto test framework.

[tools] Move nightly-test scripts into build_script/tools folder.

add op Concat and fix compile error

update code based on comments

fix the format of code

[XNNPACK] The initial commit

[XNNPACK] implement unary ops

[XNNPACK] implement add and mul

[XNNPACK] implement the 2d matmul

[XNNPACK] reimplement relu by xnn_operator_t

Support the preallocated output buffer

[XNNPACK] implement clamp

[XNNPACK] implement add and mul

[XNNPACK] implement sub and tests

[XNNPACK] implement conv2d nhwc

[XNNPACK] supports filter layout ohwi of conv2d

[XNNPACK] implement fused conv2d

[XNNPACK] implement the depthwise conv2d

[Test] Add the SubTests.cpp

[XNNPACK] build on Linux

[XNNPACK] update the README.md

[Test] git cl format SubTests.cpp

[XNNPACK] implement pool2d nhwc

[Node]Clean license with Apache 2.0

[test] Updated layout value of conv2d, pool2d options.

[XNNPACK] fix the input layout and filter layout

[Test] add hwio and oihw filter layout for nhwc tests

[Test] fix the review comments

add Op BatchNorm

fix the format

modify the code based on comments

add Op LeakyRelu

modify the code based on comments

use the options with default value for Op LeakyRelu

modify the format for LeakyRelu

add op Gemm

fix the base on the comments

delet useless code

rebase commits and modify the code based on comments

keep the options only

[SqueezeNet] Add SqueezeNet(NCHW) C++ example

[SueezeNet] Support both NCHW/NHWC layout and refactor example codes

[Examples] Refactor codes

[Examples] Pass SqueezeNet NHWC and enable input parameters

[Examples] Add readme for SqueezeNet and refactor codes

[DML] Support NHWC layout

refactor code to simplify

[fix issue] Fix issue of compiling on Windows

[Fix issue] Fix stb loading issue

add op kunliang/clamp

modify the implementation for op Clamp based on comments

support Scalar argurement for Constants on Node.js

add more type for Constant

add three private variable for different dataTpye in Constant

add Union Scalar and remove the reinterpret_cast for each type

modify Constants based on comments

[example] Keep one images folder under examples

[modelTest] Add model tests for SqueezeNet NCHW/NHWC

[IENN]Fix the issue caused by nhwc support

Updated ie_nn_c_api.dll for Windows platform.

[tool] Update nightly-test tool to test SqueezeNet examples.

[build] Add linter for checking js files.

[build] Add SqueezeNet example into build package.

[build] Enable build for oneDNN backend on Windows platform.

[build] Enable build for XNNPACK backend.

Add NHWC support for batchNormalize

[autoPad] add autoPad for conv2d/pool2d and support conv2d autoPad for IE

[autoPad] Add end2end tests for conv2d autoPad

[build] Add test data files of SqueezeNet model tests into build package.

[tool] Updated nightly test script to test examples
       with changed paths of model and weights.

[Node] Refer the constant avoid garbage collection

[git config] Add third_party/stb into .gitignore

[Node] Add README and the steps of building node addon

[IE]Fix crash issue for unimplement binary ops

[node] fix the coding style issue

fix #451

[node] fix warnings

[DML]Add support for autopad of Conv2d

Update ie dll with batchnorm nhwc implement

[mobilenetv2] Add mobilenetv2 for nchw at first

[mobilenetv2] Refactor codes and support nchw/nhwc

[Refactor] Refactor examples codes

[DML]Fix the issue for running squeezentnhwc

[Rebase] Implement new Spec API
  • Loading branch information
fujunwei committed Apr 29, 2021
1 parent b3b0548 commit 38a7261
Show file tree
Hide file tree
Showing 407 changed files with 16,873 additions and 294 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ third_party/markupsafe/
third_party/dawn
third_party/DirectML
third_party/microsoft.ai.directml*
third_party/dnnl_*
third_party/XNNPACK
third_party/stb
node/third_party/webnn-polyfill
tools
out

Expand Down Expand Up @@ -91,3 +95,5 @@ $RECYCLE.BIN/
### Node ###
node/generator/specifications
node/PATH_TO_DAWN
node/third_party/webnn-polyfill
node/node_modules
23 changes: 23 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ vars = {
}

deps = {
'third_party/stb': {
'url': '{github_git}/nothings/stb@b42009b3b9d4ca35bc703f5310eedc74f584be58'
},
'node/third_party/webnn-polyfill': {
'url': '{github_git}/webmachinelearning/webnn-polyfill.git@cd9cba8bf3b4ee0a5d98a44e40108bbd79f6bc17'
},
'third_party/dawn': {
'url': '{dawn_git}/dawn.git@bf1c0cf52377b4db2bf3a433dc5056620aad7cdd'
},
'third_party/DirectML': {
'url': '{github_git}/microsoft/DirectML.git@e1b29b20a21bd2fb669a0c774f9870f8e9731da6',
'condition': 'checkout_win',
},
'third_party/XNNPACK': {
'url': '{github_git}/google/XNNPACK.git@60fc61373f21f0ad3164cc719de464f4b787dc04'
},

# Dependencies required to use GN/Clang in standalone
'build': {
Expand Down Expand Up @@ -164,6 +173,20 @@ hooks = [
'condition': 'checkout_win',
'action': ['python3', 'src/webnn_native/dml/deps/script/download_dml.py'],
},
{
# Download the oneDNN package for Windows.
'name': 'download_onednn',
'pattern': '.',
'condition': 'checkout_win',
'action': ['python3', 'scripts/download_onednn.py', 'win'],
},
{
# Download the oneDNN package for Linux.
'name': 'download_onednn',
'pattern': '.',
'condition': 'checkout_linux',
'action': ['python3', 'scripts/download_onednn.py', 'linux'],
},
]

recursedeps = [
Expand Down
42 changes: 42 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,45 @@ SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

---------------------------------------------------------

---------------------------------------------------------

https://github.com/nothings/stb.git b42009b3b9d4ca35bc703f5310eedc74f584be58

This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ It provides several building blocks:
- **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](https://dawn.googlesource.com/dawn/) project.
* The DirectMLX and device wrapper of [DirectML](https://github.com/microsoft/DirectML) project.
* The [XNNPACK](https://github.com/google/XNNPACK)

## Build and Run

Expand Down Expand Up @@ -53,10 +56,17 @@ To build with DirectML backend, set build option `webnn_enable_dml=true`.

To build with OpenVINO backend, set build option `webnn_enable_openvino=true`.

To build with oneDNN backend, set build option `webnn_enable_onednn=true`.

To build with XNNPACK backend, set build option `webnn_enable_xnnpack=true`.

### Build

Then use `ninja -C out/Release` or `ninja -C out/Debug` to build WebNN-native.

**Notes**
* To build with XNNPACK backend, please build XNNPACK first, e.g. by [`XNNPACK/scripts/build-local.sh`](https://github.com/google/XNNPACK/blob/master/scripts/build-local.sh).

### Run tests

Run unit tests, for example `./out/Release/webnn_unittests`.
Expand All @@ -65,6 +75,7 @@ Run end2end tests, for example `./out/Release/webnn_end2end_tests`.

**Notes**:
* For OpenVINO backend, please [install 2021.2 version](https://docs.openvinotoolkit.org/2021.2/openvino_docs_install_guides_installing_openvino_linux.html#install-openvino) and [set the environment variables](https://docs.openvinotoolkit.org/2021.2/openvino_docs_install_guides_installing_openvino_linux.html#set-the-environment-variables) before running the end2end tests.
* For oneDNN backend on Linux, please set the `LD_LIBRARY_PATH` environment variable to the out folder before running the end2end tests, e.g. `LD_LIBRARY_PATH=./out/Release ./out/Release/webnn_end2end_tests`.

### Run examples

Expand Down
6 changes: 6 additions & 0 deletions build_overrides/webnn_features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ declare_args() {
# Enables the compilation of DirectML backend
webnn_enable_dml = false

# Enables the compilation of oneDNN backend
webnn_enable_onednn = false

# Enables the compilation of XNNPACK backend
webnn_enable_xnnpack = false

# Enables the compilation of WebNN's Null backend
# (required for unittests, obviously non-conformant)
webnn_enable_null = true
Expand Down
16 changes: 16 additions & 0 deletions build_script/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "google",
"parserOptions": {
"ecmaVersion": 2017
},
"plugins": [
"header"
],
"rules": {
"header/header": [2, "line",
[{"pattern": "^ Use of this source code is governed by an Apache 2\\.0 license$"},
{"pattern": "^ that can be found in the LICENSE file\\.$"}]],
"max-len": ["error", 80, 2, { "ignoreUrls": true }],
"quotes": ["error", "single"]
}
}
Loading

0 comments on commit 38a7261

Please sign in to comment.