├── .eslintrc.json ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.ja.md ├── README.md ├── example ├── benchmark │ ├── make_mobilenetv2.py │ ├── make_models.py │ ├── models │ │ └── detr.py │ └── runner │ │ ├── .gitignore │ │ ├── bench.js │ │ ├── optimized.html │ │ └── standard.html ├── custom_operator │ ├── README.ja.md │ ├── README.md │ ├── index.html │ ├── index.js │ ├── make_model.py │ └── twice.ts ├── detr │ ├── README.ja.md │ ├── README.md │ ├── common.js │ ├── conversion.py │ ├── index.html │ ├── index.js │ ├── test.html │ └── test.js ├── minimum │ ├── README.ja.md │ ├── README.md │ ├── index.html │ ├── make_model.py │ └── model │ │ └── model.onnx └── resnet │ ├── export_pytorch_model.py │ ├── imagenet_classes.js │ ├── index.html │ ├── index.js │ └── optimized.html ├── package.json ├── requirements.test.txt ├── scripts ├── extract_subgraph.py └── make_operator_entries.py ├── setup.py ├── src ├── descriptor_runner │ ├── backend │ │ ├── cpu │ │ │ ├── cpuContextImpl.ts │ │ │ └── cpuTensorImpl.ts │ │ ├── wasm │ │ │ ├── wasmContextImpl.ts │ │ │ └── wasmTensorImpl.ts │ │ ├── webgl │ │ │ ├── pack.ts │ │ │ ├── webglContextImpl.ts │ │ │ └── webglTensorImpl.ts │ │ └── webgpu │ │ │ ├── webgpuContextImpl.ts │ │ │ ├── webgpuMetaBuffer.ts │ │ │ └── webgpuTensorImpl.ts │ ├── core │ │ ├── inputProxy.ts │ │ ├── modelTransform.ts │ │ ├── operatorTable.ts │ │ ├── outputProxy.ts │ │ ├── runnerImpl.ts │ │ ├── tensorDecoder │ │ │ ├── decodeTensorEightbit.ts │ │ │ └── decodeTensorRaw.ts │ │ ├── tensorImpl.ts │ │ └── tensorLoaderImpl.ts │ ├── image.ts │ ├── image │ │ ├── canvas.ts │ │ ├── enums.ts │ │ ├── image_array.ts │ │ ├── image_data.ts │ │ └── image_source.ts │ ├── index.ts │ ├── interface │ │ ├── backend │ │ │ ├── cpu │ │ │ │ ├── cpuContext.ts │ │ │ │ └── cpuTensor.ts │ │ │ ├── wasm │ │ │ │ ├── wasmContext.ts │ │ │ │ └── wasmTensor.ts │ │ │ ├── webgl │ │ │ │ ├── webglContext.ts │ │ │ │ └── webglTensor.ts │ │ │ └── webgpu │ │ │ │ ├── webgpuContext.ts │ │ │ │ └── webgpuTensor.ts │ │ └── core │ │ │ ├── backendContext.ts │ │ │ ├── constants.ts │ │ │ ├── operator.ts │ │ │ ├── runner.ts │ │ │ ├── tensor.ts │ │ │ └── tensorLoader.ts │ ├── logging.ts │ ├── math.ts │ ├── math │ │ ├── argsort.ts │ │ └── random.ts │ ├── operators │ │ ├── base │ │ │ ├── averagepool.ts │ │ │ ├── conv.ts │ │ │ ├── convtranspose.ts │ │ │ ├── flatten.ts │ │ │ ├── gemm.ts │ │ │ ├── matmul.ts │ │ │ ├── maxpool.ts │ │ │ ├── pad11.ts │ │ │ ├── reshape5.ts │ │ │ ├── split.ts │ │ │ ├── squeeze.ts │ │ │ ├── transpose.ts │ │ │ └── unsqueeze.ts │ │ ├── cpu │ │ │ ├── opEntriesStandard.ts │ │ │ ├── operators │ │ │ │ ├── autogen │ │ │ │ │ └── .gitignore │ │ │ │ ├── custom │ │ │ │ │ └── .gitignore │ │ │ │ └── standard │ │ │ │ │ ├── averagepool.ts │ │ │ │ │ ├── binary7.ts │ │ │ │ │ ├── cast.ts │ │ │ │ │ ├── clip.ts │ │ │ │ │ ├── concat.ts │ │ │ │ │ ├── constant.ts │ │ │ │ │ ├── constantofshape.ts │ │ │ │ │ ├── conv.ts │ │ │ │ │ ├── convtranspose.ts │ │ │ │ │ ├── dynamicunary.ts │ │ │ │ │ ├── eachelementwise.ts │ │ │ │ │ ├── flatten.ts │ │ │ │ │ ├── gather.ts │ │ │ │ │ ├── gemm.ts │ │ │ │ │ ├── globalaveragepool.ts │ │ │ │ │ ├── instancenormalization.ts │ │ │ │ │ ├── matmul.ts │ │ │ │ │ ├── maxpool.ts │ │ │ │ │ ├── pad11.ts │ │ │ │ │ ├── reduce.ts │ │ │ │ │ ├── reshape5.ts │ │ │ │ │ ├── shape.ts │ │ │ │ │ ├── slice.ts │ │ │ │ │ ├── softmax.ts │ │ │ │ │ ├── split.ts │ │ │ │ │ ├── squeeze.ts │ │ │ │ │ ├── tile.ts │ │ │ │ │ ├── transpose.ts │ │ │ │ │ ├── unary.ts │ │ │ │ │ └── unsqueeze.ts │ │ │ └── rawcomputation │ │ │ │ └── averagepool.ts │ │ ├── index.ts │ │ ├── operatorImpl.ts │ │ ├── operatorUtil.ts │ │ ├── wasm │ │ │ ├── opEntriesStandard.ts │ │ │ ├── operators │ │ │ │ ├── autogen │ │ │ │ │ └── .gitignore │ │ │ │ ├── custom │ │ │ │ │ └── .gitignore │ │ │ │ └── standard │ │ │ │ │ ├── binary7.ts │ │ │ │ │ ├── dynamicunary.ts │ │ │ │ │ ├── flatten.ts │ │ │ │ │ ├── gemm.ts │ │ │ │ │ ├── reshape5.ts │ │ │ │ │ ├── squeeze.ts │ │ │ │ │ ├── unary.ts │ │ │ │ │ └── unsqueeze.ts │ │ │ └── worker │ │ │ │ └── .gitignore │ │ ├── webgl │ │ │ ├── opEntriesStandard.ts │ │ │ ├── operators │ │ │ │ ├── autogen │ │ │ │ │ └── .gitignore │ │ │ │ ├── custom │ │ │ │ │ └── .gitignore │ │ │ │ └── standard │ │ │ │ │ ├── averagepool.ts │ │ │ │ │ ├── binary7.ts │ │ │ │ │ ├── cast.ts │ │ │ │ │ ├── clip.ts │ │ │ │ │ ├── conv.ts │ │ │ │ │ ├── convtranspose.ts │ │ │ │ │ ├── flatten.ts │ │ │ │ │ ├── gemm.ts │ │ │ │ │ ├── globalaveragepool.ts │ │ │ │ │ ├── instancenormalization.ts │ │ │ │ │ ├── matmul.ts │ │ │ │ │ ├── maxpool.ts │ │ │ │ │ ├── pad11.ts │ │ │ │ │ ├── reduce.ts │ │ │ │ │ ├── reshape5.ts │ │ │ │ │ ├── softmax.ts │ │ │ │ │ ├── split.ts │ │ │ │ │ ├── squeeze.ts │ │ │ │ │ ├── transpose.ts │ │ │ │ │ ├── unary.ts │ │ │ │ │ └── unsqueeze.ts │ │ │ ├── rawcomputation │ │ │ │ └── averagepool.ts │ │ │ └── shaderHelper.ts │ │ └── webgpu │ │ │ ├── opEntriesStandard.ts │ │ │ ├── operators │ │ │ ├── custom │ │ │ │ └── .gitignore │ │ │ └── standard │ │ │ │ ├── binary7.ts │ │ │ │ ├── conv.ts │ │ │ │ ├── gemm.ts │ │ │ │ └── unary.ts │ │ │ └── shaders.ts │ ├── separateBuild │ │ ├── coreOnly.ts │ │ ├── operatorCPU.ts │ │ ├── operatorWasm.ts │ │ ├── operatorWebGL.ts │ │ └── operatorWebGPU.ts │ └── util.ts ├── graph_transpiler │ └── webdnn │ │ ├── __init__.py │ │ ├── constant_codec_eightbit.py │ │ ├── model.py │ │ ├── onnx_util.py │ │ ├── operator_shader.py │ │ ├── operator_shader_cpu.py │ │ ├── operator_shader_wasm.py │ │ ├── operator_shader_webgl.py │ │ ├── operator_shader_webgpu.py │ │ ├── optimization_pass.py │ │ ├── optimization_pass_result_cpu.py │ │ ├── optimization_pass_result_wasm.py │ │ ├── optimization_pass_result_webgl.py │ │ ├── optimize_model.py │ │ ├── parse_onnx.py │ │ ├── pass_conv_reshape_webgl.py │ │ ├── pass_fusion_unary.py │ │ ├── pass_fusion_unary_cpu.py │ │ ├── pass_fusion_unary_wasm.py │ │ ├── pass_fusion_unary_webgl.py │ │ ├── pass_matmul_transpose_webgl2.py │ │ ├── passes.py │ │ ├── tensor_export.py │ │ └── util.py └── shader │ ├── wasm │ ├── compile.py │ ├── pre.js │ └── src │ │ ├── common │ │ ├── binary7.hpp │ │ ├── kernel.hpp │ │ └── unary.hpp │ │ ├── core │ │ └── allocation.cpp │ │ └── kernels │ │ ├── autogen │ │ └── .gitignore │ │ ├── custom │ │ └── .gitignore │ │ └── standard │ │ ├── binary7s.cpp │ │ ├── copy.cpp │ │ ├── dynamic_unarys.cpp │ │ ├── gemm.cpp │ │ └── unarys.cpp │ └── webgpu │ ├── compile.js │ └── shadersources │ ├── autogen │ └── .gitignore │ ├── custom │ └── .gitignore │ └── standard │ ├── binary_broadcast_add_0d.glsl │ ├── binary_broadcast_add_1d.glsl │ ├── binary_broadcast_add_2d.glsl │ ├── binary_broadcast_add_3d.glsl │ ├── binary_broadcast_add_4d.glsl │ ├── binary_elementwise_add.glsl │ ├── conv_bias.glsl │ ├── conv_im2col.glsl │ ├── conv_matmul.glsl │ ├── conv_transpose.glsl │ ├── gemm.glsl │ └── relu.glsl ├── test └── model_test │ ├── make_models.py │ └── runner │ ├── .gitignore │ ├── optimized.html │ ├── standard.html │ └── test.js ├── tsconfig.json ├── webpack-core.config.js ├── webpack-cpu.config.js ├── webpack-wasm.config.js ├── webpack-webgl1-16384.config.js ├── webpack-webgl1-4096.config.js ├── webpack-webgl2-16384.config.js ├── webpack-webgl2-4096.config.js ├── webpack-webgpu.config.js ├── webpack.config.js └── yarn.lock /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:@typescript-eslint/eslint-recommended", 5 | "plugin:@typescript-eslint/recommended", 6 | "plugin:prettier/recommended" 7 | ], 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "env": { "node": true, "es6": true }, 12 | "parser": "@typescript-eslint/parser", 13 | "parserOptions": { 14 | "sourceType": "module", 15 | "project": "./tsconfig.json" 16 | }, 17 | "rules": { 18 | } 19 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | /dist 64 | *.egg-info 65 | __pycache__ 66 | output 67 | 68 | # custom operator related 69 | /src/descriptor_runner/operators/cpu/opEntriesAll.ts 70 | /src/descriptor_runner/operators/wasm/opEntriesAll.ts 71 | /src/descriptor_runner/operators/webgl/opEntriesAll.ts 72 | /src/descriptor_runner/operators/webgpu/opEntriesAll.ts 73 | /src/descriptor_runner/custom 74 | /src/shader/wasm/lib 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | We welcome contributions to WebDNN. This document describes the procedures and rules. 3 | 4 | Kinds of contributions will be one of the following, but not restricted to: 5 | - Bugfix 6 | - Implementation of a layer 7 | - Implementation of a converter from a deep learning framework 8 | - Improvement of performance 9 | - Documantation 10 | 11 | For new layer implementation, at least WebAssembly backend implementation is required. WebGPU backend can only be tested on Mac, so it is not mandatory. 12 | 13 | # Testing 14 | If you have added some features, implementing tests corresponding to them is recommended. 15 | 16 | `test/webdnn_test` is for tests which can be completed within graph transpiler. `test/runtime` is for tests which generates graph descriptor and compares its behavior on web browsers. 17 | 18 | See how to run test commands in `test/README.md`. 19 | 20 | # Pull Request 21 | Send pull request from your fork branch to our master branch. The project organizer checks the request and accepts or gives request for revision. 22 | 23 | # License 24 | WebDNN is distributed under the MIT License. Every contributor holds the copyright of his/her part. 25 | 26 | By contributing to the mil-tokyo/webdnn repository through pull-request, comment, 27 | or otherwise, the contributor releases their content to the license and copyright 28 | terms herein. 29 | 30 | ## Developer Certificate of Origin 1.1 31 | Developer Certificate of Origin 32 | Version 1.1 33 | 34 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 35 | 1 Letterman Drive 36 | Suite D4700 37 | San Francisco, CA, 94129 38 | 39 | Everyone is permitted to copy and distribute verbatim copies of this 40 | license document, but changing it is not allowed. 41 | 42 | 43 | Developer's Certificate of Origin 1.1 44 | 45 | By making a contribution to this project, I certify that: 46 | 47 | (a) The contribution was created in whole or in part by me and I 48 | have the right to submit it under the open source license 49 | indicated in the file; or 50 | 51 | (b) The contribution is based upon previous work that, to the best 52 | of my knowledge, is covered under an appropriate open source 53 | license and I have the right under that license to submit that 54 | work with modifications, whether created in whole or in part 55 | by me, under the same open source license (unless I am 56 | permitted to submit under a different license), as indicated 57 | in the file; or 58 | 59 | (c) The contribution was provided directly to me by some other 60 | person who certified (a), (b) or (c) and I have not modified 61 | it. 62 | 63 | (d) I understand and agree that this project and the contribution 64 | are public and that a record of the contribution (including all 65 | personal information I submit with it, including my sign-off) is 66 | maintained indefinitely and may be redistributed consistent with 67 | this project or the open source license(s) involved. 68 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Machine Intelligence Laboratory (The University of Tokyo) 4 | and other contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | By contributing to the mil-tokyo/webdnn repository through pull-request, comment, 25 | or otherwise, the contributor releases their content to the license and copyright 26 | terms herein. 27 | 28 | ---- 29 | 30 | # lib/inflate.min.js 31 | /** 32 | * @license 33 | * zlib.js 34 | * JavaScript Zlib Library 35 | * https://github.com/imaya/zlib.js 36 | * 37 | * The MIT License 38 | * 39 | * Copyright (c) 2012 imaya 40 | * 41 | * Permission is hereby granted, free of charge, to any person obtaining a copy 42 | * of this software and associated documentation files (the "Software"), to deal 43 | * in the Software without restriction, including without limitation the rights 44 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 45 | * copies of the Software, and to permit persons to whom the Software is 46 | * furnished to do so, subject to the following conditions: 47 | * 48 | * The above copyright notice and this permission notice shall be included in 49 | * all copies or substantial portions of the Software. 50 | * 51 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 52 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 53 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 54 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 55 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 56 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 57 | * THE SOFTWARE. 58 | */ 59 | 60 | # Photos used for examples have their own licenses 61 | 62 | -------------------------------------------------------------------------------- /README.ja.md: -------------------------------------------------------------------------------- 1 | # WebDNN 2 | 3 | [English](README.md) 4 | 5 | WebDNN version 2のα版です。WebDNN 1.xとの大きな違いは、入力としてONNX形式のモデルのみを受け付ける点です。Pythonによる前処理なしで、ONNXモデルを直接Webブラウザで読み込むことが可能です。さらに、オフラインでのモデル最適化を行うことも可能です。 6 | 7 | [Version 1.x](https://github.com/mil-tokyo/webdnn/tree/v1.2.11) 8 | 9 | # 対応バックエンド(高速化技術) 10 | 11 | モダンブラウザのほとんどで、WebGLが使用可能。 12 | 13 | - WebGPU 14 | - Chrome Canary搭載版。 15 | - iOS13に搭載のWebGPUは廃止予定のWSL言語によるシェーダを必要とするため非対応。 16 | - WebGL 17 | - WebGL2が使用可能な場合は使用する。WebGL1のみ対応のSafariにも対応。 18 | - WebAssembly 19 | 20 | # 開発環境セットアップ 21 | 22 | node.js 14, python 3.6以降, emscripten 2.0以降が動作する環境が必要です。 23 | 24 | ``` 25 | yarn 26 | python setup.py develop 27 | ``` 28 | 29 | # ビルド 30 | ``` 31 | yarn build:all 32 | ``` 33 | 34 | ビルド成果物 35 | - `dist/webdnn.js` 36 | - 最適化されていないONNXモデルを読み込むことができるライブラリ 37 | - `dist/webdnn-core.js` 38 | - WebDNNにより最適化されたモデルを読み込むことができるライブラリ 39 | 40 | # 基本的な使い方 41 | 42 | `dist/webdnn.js`を` 9 | 10 | 11 |
12 |