Commit graph

55 commits

Author SHA1 Message Date
shalvamist
5c16e0befb
[web] utility functions for tensor<->image conversion in ORT web (#13603)
### Description
Data processing capabilities to ORT Web. 
This PR will focus augmenting raw data to and from Tensors.

### Motivation and Context
Enabling different app building use cases to leverage ORT in a more
natural form.
Currently, the user needs to process the data and call Tensor
constructors - these util functions will provide a direct path to
generating ORT tensors.

Co-authored-by: shalvamist <shalva.mist@microsoft.com>
2023-01-12 09:05:18 -08:00
Seungwon Jeong
307ad1413a
[js/web] support 'pytorch_half_pixel' mode for WebGL kernel 'Resize' (#11208)
**Description**: 
1. add pytorch_half_pixel interpolation mode in resize-packed.ts
Changes: add the following case in createPackedResizeProgramInfo
function:
```
case 'pytorch_half_pixel':
          getSourceFracIndex = `
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 fcoords = vec4(coords);
                        return vec4(
                            ${outputWidth}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
                            ${outputHeight}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
                            ${outputWidth}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
                            ${outputHeight}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
                          );
                    }
                `;
          break;
```
2. fix "unrecognized input '' for node: Resize_$num" error when inputs
like [input_tensor, None, scale_factor] (roiInput not given) are fed
into the resize layer.
Changes: change in input handling logic in upsample.ts & node scanning
logic in graph.ts

**Motivation and Context**
Before this fix, we aren't able to use webGL backend when the neural
network contains pytorch resize layers. This fix adds
'pytorch_half_pixel' interpolation mode support and makes it possible to
use webGL backend for more kind of computer vision networks.

This commit solves:
#10430

Co-authored-by: neo <neo@icode-lab.com>
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
2022-11-21 12:03:48 -08:00
Guenther Schmuelling
6f6560a7b9
fix to reduce peak memory usage in ort-web (#13323)
fix to reduce peak memory usage in ort-web
2022-11-14 12:18:02 -08:00
Yulong Wang
82786baed1
[js/web] add 'xnnpack' to EP list (#12723)
**Description**: This PR adds support for "XNNPACK EP" in ORTWeb and
changes the behavior of how ORTWeb deals with "backends", or "EPs" in
API.

**Background**: Term "backend" is introduced in ONNX.js to representing
a TypeScript type which implements a "backend" interface, which is a
similar but different concept to ORT's EP (execution provider). There
was 3 backends in ONNX.js: "cpu", "wasm" and "webgl".

When ORT Web is launched, the concept is derived to help users to
integrate smoothly. Technically, when "wasm" backend is used, users need
to also specify "EP" in the session options. Considering it may get
complicated and confused for users to figure out the difference between
"backend" and "EP", the JS API hide the "backend" concept and made a
mapping between names, backends and EPs:
"webgl" (Name) <==> "onnxjsBackend" (Backend)
"wasm" (Name) <==> "wasmBackend" (Backend) <==> "CPU" (EP)

**Details**:
The following changes are applied in this PR:
1. allow multi-registration for backends using the same name. This is
for use scenarios where both "onnxruntime-node" and "onnxruntime-web"
are consumed in a Node.js App ( so "cpu" will be registered twice in
this scenario. )
2. re-assign priority values to backends. I give 100 as base to "cpu"
for node and react_native, and 10 as base to "cpu" in web.
3. add "cpu", "xnnpack" as new names of backends.
4. update onnxruntime wasm exported functions to support EP
registration.
5. update implementations in ort web to handle execution providers in
session options.
6. add '--use_xnnpack' as default build flag for ort-web
2022-10-03 10:38:45 -07:00
shalvamist
851b0ce936
[js/web][Fix] - updating the C API to catch non-tensor data (#12811)
Added a check for tensor validation on the input - this change fixes the
quiet abort WASM takes when processing a non tensor data in
"OrtGetTensorData"

**Motivation and Context**
At the current status when we try to process non-tensor data through
OrtGetTensorData and exception is thrown which results in a quiet abort
from WASM (assuming WASM was built without exception handling).

I added a check in the C API to catch this case and output a meaningful
message to the user

[example_error_github_12622.zip](https://github.com/microsoft/onnxruntime/files/9464328/example_error_github_12622.zip)
2022-09-21 13:59:17 -07:00
Yulong Wang
1a402a3f25
replace 'master' branch ref to 'main' for onnx repo (#12678) 2022-08-30 13:41:42 -07:00
Yulong Wang
f40e90c33f
[js/web] fix incorrect shader for 'Resize' (#12588) 2022-08-21 21:47:28 -07:00
101arrowz
148b1efe5e
[js/web] add ConvTranspose2D to WebGL backend (#11990)
* Add ConvTranspose

* Update docs + tests

* fix lint

* fix output shape calculations

* Revert "fix output shape calculations"

This reverts commit 8014fa9b33115f1d6a677fe2270a6da1b510ff67.

* fix format

* remove broken output_shape test
2022-07-27 13:57:12 -07:00
101arrowz
c72bb8aaa9
[js/web] add OffscreenCanvas support to WebGL backend (#12159)
* Add OffscreenCanvas support to WebGL backend

* fix format

* fix lint
2022-07-20 14:06:03 -07:00
Yosshi999
0702364d7a
[js/web][bugfix] fix negative axes for unsqueeze (#11944)
[js/web] fix negative axes for unsqueeze
2022-06-28 11:28:35 -07:00
Yulong Wang
af21a04977
[js] upgrade async@3.2.3 /js/ (#11421)
* [js] upgrade async@3.2.3 /js/

* format code
2022-05-03 23:41:36 -07:00
Yulong Wang
6c7090a829
[js/web] fix output type mapping (#11049) 2022-03-30 16:26:04 -07:00
Yulong Wang
893ee65e54
[js/web] fix lint error when run without ort-web TS types (#10429)
* [js/web] fix lint error when run without ort-web TS types

* update CI to run linter before 'npm ci' in /js/web
2022-02-17 22:34:38 -08:00
Yulong Wang
b9909f985e
[js/web] rename build-def.ts to build-def.d.ts (#9954) 2021-12-09 14:17:42 -08:00
Yulong Wang
a3ebc5e082
[js/web] do not use nodejs type 'Buffer' in web (#9839)
* [js/web] do not use nodejs type 'Buffer' in web

* resolve comments and validate tests

* remove 'Buffer' in test
2021-11-24 14:14:42 -08:00
Yulong Wang
74ca417c0e
[js/web] optimize bundle file size (#9817)
* es2017 by default for ort-common

* add visualizer and define plugin

* es2017 for ort-web. also add build target for es5

* add multiple reduced size build for ort-web

* resolve comments, add e2e tests and add docs
2021-11-22 13:56:55 -08:00
Sunghoon
e65f284476
[js/web] Support WebGL for ort format models in benchmarks (#9661)
* add p50 in test

* Support FusedConv in WebGL

* resolve comments

* add a comment for longToNumber change

Co-authored-by: Yulong Wang <yulongw@microsoft.com>
2021-11-09 11:58:47 -08:00
Sunghoon
c79307e7b4
[js/web] support opset-13 of softmax (#9493)
* add p50 in test

* support opset-13 of softmax

* update a operators.md

* resolve comments

* fix lint and format

Co-authored-by: Yulong Wang <yulongw@microsoft.com>
2021-10-26 23:58:50 -07:00
Yulong Wang
901c7de918
[js/web] remove webgl from default fallback list (#9374) 2021-10-14 21:46:22 -07:00
Sunghoon
74eaaad768
[js/web] Support opset-13 for squeeze, unsqueeze, maxpool, pad, cast and clip (#9249)
* Support opset-13 for squeeze, unsqueeze, maxpool, pad, cast, clip

* merge master and update a operators.md

* resolve comment. revise pool and cast kernel implementation.

* skip fusion when clip min and max is not in initializer
2021-10-14 16:29:37 -07:00
Yulong Wang
634bb5ede0
fix CodeQL warning 'Remote property injection' (#9224) 2021-09-30 13:45:22 -07:00
Yulong Wang
8c57d51928
support WebAssembly SIMD for qgemm (#9191)
* support WebAssembly SIMD for qgemm

* remove '--experimental-wasm-bulk-memory' for test
2021-09-30 12:40:56 -07:00
Yulong Wang
750e2e0481
[js/web] check session ID in releaseSession() (#9105) 2021-09-20 17:49:53 -07:00
Yulong Wang
be80698698
[js/web] a bugfix and add tests for wasm proxy worker (#9048)
* [js/web] add tests for wasm proxy worker

* fix script src override
2021-09-14 10:38:58 -07:00
Du Li
57b7ab56cd
Adding async fetching for webgl backend (#8951)
* Adding async fetching for webgl backend

* fix PR comments and CI failure.

* fixing a bug

* adding a flag
2021-09-09 22:17:42 -07:00
Sunghoon
450524359e
[js/web] WebAssembly profiling (#8932)
* add p50 in test

* Preallocate WebAssembly worker threads to minimize worker creation time

* WebAssembly profiling

* merge master

* merge with proxy changes

* disable profiling tests from WebAssembly build

* fix e2e test failure

Co-authored-by: Yulong Wang <yulongw@microsoft.com>
2021-09-07 17:18:08 -07:00
Yulong Wang
206537936f
[js/web] enable proxy worker for wasm backend (#8862) 2021-08-31 10:23:42 -07:00
Yulong Wang
cb67fca738
[js/web] enable 'use_ort_model_bytes_directly' by default (#8734) 2021-08-18 11:18:58 -07:00
Yulong Wang
4ceedbe933
[js/web] add SharedArrayBuffer check for wasm multi-thread (#8749) 2021-08-16 23:17:54 -07:00
Yulong Wang
3e8cabbc3e
[js/web] WebGL backend refactor (#8586) 2021-08-12 12:30:49 -07:00
Yulong Wang
f3a1aebb33
[js/web] support override wasm file path (#8610) 2021-08-05 18:01:03 -07:00
Du Li
fa722d208b
[js/web] adding webgl pointwise conv kernel (#8418) 2021-08-04 20:46:08 -07:00
Tixxx
db88f3059c
[js] fixing broadcast issues in pack mode (#8090)
* fixing broadcast issues in pack mode

* improved bcast logic for matmul

* removed TODO

* rebased from master
2021-06-23 09:55:19 -07:00
Du Li
352d560fd5
Adding Conv+Clip fusion (#8102) 2021-06-21 16:30:12 -07:00
Du Li
b50e9d9d74
Adding webgl shape kernel (#7971) 2021-06-08 06:22:45 -07:00
Gao, Chun
0f01de3b0b
[js/web] Add wasm SIMD backend to onnxruntime-web (#7896)
* [js/web] Add wasm SIMD backend to onnxruntime-web

* Import SIMD wasm artifacts enabled by PR #7839

* Detect SIMD capability of web engine

* Use SIMD wasm backend in both single-thread and multi-thread cases

* update optimized SIMD loading from ort web

* code lint and format

* fix WasmFileName in CI

* replace deprecated wasm SIMD functions

* fix unittest for simd

* optimize CI pipeline to merge build matrix

* make clean build for each config

* fix simd wasm to enable it.

* update script/pull-prebuilt-wasm-artifacts.ts

Co-authored-by: Yulong Wang <yulongw@microsoft.com>
Co-authored-by: Lei Zhang <zhang.huanning@hotmail.com>
2021-06-07 23:24:27 -07:00
Du Li
6a9023f47d
[JS/Web]Adding support for WebGL v1 (#7906)
* Adding support for WebGL v1

* enabling a few tests

* Minor changes for README.md
2021-06-03 21:30:42 -07:00
Yulong Wang
896f32ec09
[js/web] support string tensor for wasm backend (#7891)
* [js/web] support string tensor for wasm backend

* disable v9/test_cast_STRING_to_FLOAT: test data is wrong

* add non-string check

* Update session-handler.ts

* Update session-handler.ts
2021-06-03 00:44:50 -07:00
Tixxx
2a3851cd75
fixed bugs in packed mode and enable pack mode tests in ci (#7848)
* fixed bugs in packed mode and enable pack mode tests in ci

* removed unnecessary space

* pr comments

* pr comments

* disable an average pool test

* try disabling another avg pool

* disable more avg pool tests

* disable maxpool tests
2021-05-27 07:56:58 -07:00
Yulong Wang
331f20428c
[js/web] only apply max thread number when it's omitted (#7834) 2021-05-26 15:46:50 -07:00
Tixxx
ea1a4f8fb5
[JS]support running super resolution model using ortweb (#7677)
* migrated changes to support running super resolution model using ortweb

* reverted benchmarking tool related changes which will be in a separate pr

* added kernel tests to op and node tests

* minor change to the order of variables

* added one more unit test for packed matmul
2021-05-25 17:43:43 -07:00
Du Li
fbe6eccc65
[JS/Web] Bug fix for Reshape Pack (#7754) 2021-05-19 11:15:47 -07:00
Du Li
e4a985ff17
[JS/Web] WebGL Profiling Tool (#7724) 2021-05-18 06:31:00 -07:00
Du Li
d3c4b70ede
[Web/JS] Fixing two bugs in reshape_pack and im2col_pack (#7689)
* fixing two bugs in reshape_pack and im2col_pack

* minor fix

* fix lint complaints
2021-05-17 18:28:09 -07:00
Sunghoon
da5f24bd2d
Support additional session options and run options in WebAssembly (#7712)
* add all session options and run options in C API except AddInitializer and AddFreeDimensionOverride

* remove unnecessary comment

* change extra session and run options to object notation

* resolve comments

* use an optional chaining for options

* resolve comments
2021-05-17 14:57:19 -07:00
Tixxx
6d9f541442
[JS]moved logging level flag to global env (#7700)
* moved logging level flag to global env

* added setter and getter for loggingLevel in Env

* moved implementation of env to a separate file
2021-05-17 14:16:59 -07:00
Yulong Wang
97d9bcd644
[js/web] fix bundle for multi-thread, add e2e test and support nodejs (#7688)
* fix bundle for multi-thread, add e2e test and support nodejs

* add copyright banner

* resolve comments

* add comments for isMultiThreadSupported()
2021-05-14 18:15:38 -07:00
Xueyun Zhu
32d8278c2f
reshape fix (#7678) 2021-05-13 16:34:03 -07:00
Sunghoon
1ab8a95eb6
Bind existing SessionOptions and RunOptions in Javascript API with WebAssembly (#7621)
* support session options and run options. use onnxruntime c api.

* fix lint errors

* add an error code on throwing an exception

* resolve comments. change remaining C++ APIs to C API
2021-05-13 10:50:04 -07:00
Xueyun Zhu
c5d28097e8
[js/web] adding conv fuse logic (#7604)
* adding conv fuse logic

* fixing merge

* fix file name in kebab case

* fix lint error
2021-05-10 11:41:50 -07:00