Skip to content

Commit 14cc02c

Browse files
fs-eireskottmckay
andauthored
[js/web] WebGPU backend via JSEP (#14579)
### Description This change introduced the following new components into ONNX Runtime Web: - JavaScript Execution Provider (JSEP) - Asynchronized inferencing execution powered by Emscripten's Asyncify - WebGPU backend implemented in TypeScript - initial implementation of kernels: - elementwise operators (22) - binary operators (5) - tensor: Shape, Reshape, Transpose, Gemm - nn: Conv, {Global}Maxpool, {Global}AveragePool Code need to be polished. still working on it. ## Q&A What is JSEP? > JSEP, aka JavaScript Execution Provider, is a new ONNXRuntime execution provider that specifically works on Web environment (browsers). JSEP allows JavaScript code to kick in from various places when ONNX Runtime inferences a model. Why JSEP? > JSEP is a hybrid mode EP that contains both C/C++ and TypeScript/JavaScript implementation. There are 2 strong reasons why we introduces JSEP: > 1. the C/C++ part helps JSEP to leverage ONNX Runtime's capabilities as much as possible including graph transformer, optimizers and also the capabilities to fallback to CPU EP. TypeScript/JavaScript helps JSEP to develop and debug much easier in the browser for the kernel implementation. > 2. the requirement of asynchronized execution from JavaScript API (eg. `buffer.mapAsync()`) makes it impossible to run `OrtRun()` in a synchronized context (see "async problem" section below). This is done by using Emscripten's Asyncify. What is WebGPU? > WebGPU is the new GPU API that available in browser. It's one of the only 2 APIs that currently available to access the GPU from browser (the other is WebGL). > WebGPU is designed with more advanced and stronger features comparing to WebGL and is potentially solution that offer the best GPU performance for model inferencing that currently available. What is the async problem and why we have the problem? > The "async problem" is a problem that you cannot call an async function in a synchronous context. Think about the following C++ code: > ```c > // C-style declarations (API) > typedef void (*ON_COMPLETE)(PVOID state, DATA *data); > void read_data_from_file(FILEHANDLE file, ON_COMPLETE on_complete); > > // implementation > DATA * my_impl_read_data_from_file_sync(FILEHANDLE file) { > // how to implement? > } > ``` > The answer is, it's impossible to implement this function. Usually we try to find a sync version API, or launch a thread to call the async function and sync-wait on the main thread. Unfortunately, in browser environment, neither is possible. > > WebGPU does not offer any synchronized API for data downloading (GPU to CPU). This is the only operation that MUST be async. As `OrtRun()` will eventually call into DataTransfer for copy data from GPU to CPU, and `OrtRun()` is a synchronized function, this cannot be done in normal way. What is Emscripten? How is the Asyncify feature resolved the problem? > Emscripten is the C/C++ compiler for WebAssembly. It's what we use to compile ORT and generates the WebAssembly artifacts which runs on browsers. > > Asyncify is a [compiler feature](https://emscripten.org/docs/porting/asyncify.html) that allows calling async functions from a synchronized context. In short, it generates code to unwind and rewind call stack to emulate async execution. With this feature, we are able to call the async function inside `OrtRun()` call. ## Design Overview **Inter-op** JSEP is doing pretty much same thing to just another EP. It exposes an interface for inter-op with JavaScript, which is defined in onnxruntime/wasm/js_internal_api.js: ```js // init JSEP Module["jsepInit"] = function (backend, alloc, free, copy, copyAsync, createKernel, releaseKernel, run) { Module.jsepBackend = backend; Module.jsepAlloc = alloc; Module.jsepFree = free; Module.jsepCopy = copy; Module.jsepCopyAsync = copyAsync; Module.jsepCreateKernel = createKernel; Module.jsepReleaseKernel = releaseKernel; Module.jsepRun = run; }; ``` This simple JavaScript snippet defines all language barrier level functions that requires by JSEP to achieve implementing kernels and data transfers using JavaScript inside ONNX Runtime: - `jsepBackend`: assign the singleton object to webassembly module - `jsepAlloc` and `jsepFree`: implementation of data transfer's Alloc() and Free() - `jsepCopy`: synchronized copy ( GPU to GPU, CPU to GPU) - `jsepCopyAsync`: asynchronized copy ( GPU to CPU) - `jsepCreateKernel` and `jsepReleaseKernel`: a corresponding object that maintained in JS to match lifecycle of Kernel in ORT - `jsepRun`: OpKernel::Compute() should call into this The abstraction above allows to tie as little as possible connections and dependencies between C/C++ and TypeScript/JavaScript. **Resource Management** Lifecycle of tensor data and kernels are managed by ORT(C/C++) but the implementation are left to JavaScript. JavaScript code are responsible to implement the callbacks correctly. For WebGPU, the GPU data is managed by JavaScript using a singleton map (tensot_data_id => GPUBuffer). GPU pipeline is managed as singleton. Shaders are managed using a singletonmap (shader_key => gpu_program), while shader_key is generated by cache_key (OP specific, including attributes) and input shapes. **about data transfer** `js::DataTransfer::CopyTensor` implemented to call either synchronized or asynchronized copy callback, depending on the destination is GPU or not. Emscripten's macro `EM_ASYNC_JS` is used to wrap the async function to be called in the synchronized context. **run kernel in JS** Kernel class constructor calls once `jsepCreateKernel()` with an optional per-kernel specific serialization to pass attributes into JavaScript. `Compute()` are implemented in a way that a metadata serialization is performed in a base class and JavaScript code can access the data using the Emscripten specific builtin macro `EM_ASM_*`. **disabled features** memory pattern is force disabled, because the WebGPU data is not presented by a general memory model (a buffer can be represented by offset + size). concurrent run support is disabled. WebGPU is stateful and it also has async function call. To support concurrent run will significantly increase the complexity and we don't get any real benefit from it. **prefer channels last** JSEP prefers channels last and returns `DataLayout::NHWC` in method `GetPreferredLayout()`. This will let the graph transformers to preprocess the graph into a channels last form so that a more optimized WebGPU shader can be used. **Testing code** It's impossible to test JSEP directly because JSEP itself does not contain any kernel implementation. However, it has the kernel registration which need to work together with the corresponding JavaScript code. There are unit tests that run onnx models from JavaScript API. --------- Co-authored-by: Scott McKay <[email protected]>
1 parent 8dd32fe commit 14cc02c

File tree

92 files changed

+8091
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+8091
-394
lines changed

ThirdPartyNotices.txt

Lines changed: 215 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5422,8 +5422,8 @@ _____
54225422

54235423
Tencent/rapidjson, https://github.com/Tencent/rapidjson
54245424

5425-
Tencent is pleased to support the open source community by making RapidJSON available.
5426-
5425+
Tencent is pleased to support the open source community by making RapidJSON available.
5426+
54275427
Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
54285428

54295429
If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License.
@@ -5435,13 +5435,13 @@ Other dependencies and licenses:
54355435
Open Source Software Licensed Under the BSD License:
54365436
--------------------------------------------------------------------
54375437

5438-
The msinttypes r29
5439-
Copyright (c) 2006-2013 Alexander Chemeris
5438+
The msinttypes r29
5439+
Copyright (c) 2006-2013 Alexander Chemeris
54405440
All rights reserved.
54415441

54425442
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
54435443

5444-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5444+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
54455445
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
54465446
* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
54475447

@@ -5450,7 +5450,7 @@ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPR
54505450
Open Source Software Licensed Under the JSON License:
54515451
--------------------------------------------------------------------
54525452

5453-
json.org
5453+
json.org
54545454
Copyright (c) 2002 JSON.org
54555455
All Rights Reserved.
54565456

@@ -5784,3 +5784,212 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57845784
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57855785
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57865786
SOFTWARE.
5787+
5788+
_____
5789+
5790+
TensorFlow.js
5791+
5792+
https://github.com/tensorflow/tfjs
5793+
5794+
5795+
Apache License
5796+
Version 2.0, January 2004
5797+
http://www.apache.org/licenses/
5798+
5799+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5800+
5801+
1. Definitions.
5802+
5803+
"License" shall mean the terms and conditions for use, reproduction,
5804+
and distribution as defined by Sections 1 through 9 of this document.
5805+
5806+
"Licensor" shall mean the copyright owner or entity authorized by
5807+
the copyright owner that is granting the License.
5808+
5809+
"Legal Entity" shall mean the union of the acting entity and all
5810+
other entities that control, are controlled by, or are under common
5811+
control with that entity. For the purposes of this definition,
5812+
"control" means (i) the power, direct or indirect, to cause the
5813+
direction or management of such entity, whether by contract or
5814+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
5815+
outstanding shares, or (iii) beneficial ownership of such entity.
5816+
5817+
"You" (or "Your") shall mean an individual or Legal Entity
5818+
exercising permissions granted by this License.
5819+
5820+
"Source" form shall mean the preferred form for making modifications,
5821+
including but not limited to software source code, documentation
5822+
source, and configuration files.
5823+
5824+
"Object" form shall mean any form resulting from mechanical
5825+
transformation or translation of a Source form, including but
5826+
not limited to compiled object code, generated documentation,
5827+
and conversions to other media types.
5828+
5829+
"Work" shall mean the work of authorship, whether in Source or
5830+
Object form, made available under the License, as indicated by a
5831+
copyright notice that is included in or attached to the work
5832+
(an example is provided in the Appendix below).
5833+
5834+
"Derivative Works" shall mean any work, whether in Source or Object
5835+
form, that is based on (or derived from) the Work and for which the
5836+
editorial revisions, annotations, elaborations, or other modifications
5837+
represent, as a whole, an original work of authorship. For the purposes
5838+
of this License, Derivative Works shall not include works that remain
5839+
separable from, or merely link (or bind by name) to the interfaces of,
5840+
the Work and Derivative Works thereof.
5841+
5842+
"Contribution" shall mean any work of authorship, including
5843+
the original version of the Work and any modifications or additions
5844+
to that Work or Derivative Works thereof, that is intentionally
5845+
submitted to Licensor for inclusion in the Work by the copyright owner
5846+
or by an individual or Legal Entity authorized to submit on behalf of
5847+
the copyright owner. For the purposes of this definition, "submitted"
5848+
means any form of electronic, verbal, or written communication sent
5849+
to the Licensor or its representatives, including but not limited to
5850+
communication on electronic mailing lists, source code control systems,
5851+
and issue tracking systems that are managed by, or on behalf of, the
5852+
Licensor for the purpose of discussing and improving the Work, but
5853+
excluding communication that is conspicuously marked or otherwise
5854+
designated in writing by the copyright owner as "Not a Contribution."
5855+
5856+
"Contributor" shall mean Licensor and any individual or Legal Entity
5857+
on behalf of whom a Contribution has been received by Licensor and
5858+
subsequently incorporated within the Work.
5859+
5860+
2. Grant of Copyright License. Subject to the terms and conditions of
5861+
this License, each Contributor hereby grants to You a perpetual,
5862+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5863+
copyright license to reproduce, prepare Derivative Works of,
5864+
publicly display, publicly perform, sublicense, and distribute the
5865+
Work and such Derivative Works in Source or Object form.
5866+
5867+
3. Grant of Patent License. Subject to the terms and conditions of
5868+
this License, each Contributor hereby grants to You a perpetual,
5869+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5870+
(except as stated in this section) patent license to make, have made,
5871+
use, offer to sell, sell, import, and otherwise transfer the Work,
5872+
where such license applies only to those patent claims licensable
5873+
by such Contributor that are necessarily infringed by their
5874+
Contribution(s) alone or by combination of their Contribution(s)
5875+
with the Work to which such Contribution(s) was submitted. If You
5876+
institute patent litigation against any entity (including a
5877+
cross-claim or counterclaim in a lawsuit) alleging that the Work
5878+
or a Contribution incorporated within the Work constitutes direct
5879+
or contributory patent infringement, then any patent licenses
5880+
granted to You under this License for that Work shall terminate
5881+
as of the date such litigation is filed.
5882+
5883+
4. Redistribution. You may reproduce and distribute copies of the
5884+
Work or Derivative Works thereof in any medium, with or without
5885+
modifications, and in Source or Object form, provided that You
5886+
meet the following conditions:
5887+
5888+
(a) You must give any other recipients of the Work or
5889+
Derivative Works a copy of this License; and
5890+
5891+
(b) You must cause any modified files to carry prominent notices
5892+
stating that You changed the files; and
5893+
5894+
(c) You must retain, in the Source form of any Derivative Works
5895+
that You distribute, all copyright, patent, trademark, and
5896+
attribution notices from the Source form of the Work,
5897+
excluding those notices that do not pertain to any part of
5898+
the Derivative Works; and
5899+
5900+
(d) If the Work includes a "NOTICE" text file as part of its
5901+
distribution, then any Derivative Works that You distribute must
5902+
include a readable copy of the attribution notices contained
5903+
within such NOTICE file, excluding those notices that do not
5904+
pertain to any part of the Derivative Works, in at least one
5905+
of the following places: within a NOTICE text file distributed
5906+
as part of the Derivative Works; within the Source form or
5907+
documentation, if provided along with the Derivative Works; or,
5908+
within a display generated by the Derivative Works, if and
5909+
wherever such third-party notices normally appear. The contents
5910+
of the NOTICE file are for informational purposes only and
5911+
do not modify the License. You may add Your own attribution
5912+
notices within Derivative Works that You distribute, alongside
5913+
or as an addendum to the NOTICE text from the Work, provided
5914+
that such additional attribution notices cannot be construed
5915+
as modifying the License.
5916+
5917+
You may add Your own copyright statement to Your modifications and
5918+
may provide additional or different license terms and conditions
5919+
for use, reproduction, or distribution of Your modifications, or
5920+
for any such Derivative Works as a whole, provided Your use,
5921+
reproduction, and distribution of the Work otherwise complies with
5922+
the conditions stated in this License.
5923+
5924+
5. Submission of Contributions. Unless You explicitly state otherwise,
5925+
any Contribution intentionally submitted for inclusion in the Work
5926+
by You to the Licensor shall be under the terms and conditions of
5927+
this License, without any additional terms or conditions.
5928+
Notwithstanding the above, nothing herein shall supersede or modify
5929+
the terms of any separate license agreement you may have executed
5930+
with Licensor regarding such Contributions.
5931+
5932+
6. Trademarks. This License does not grant permission to use the trade
5933+
names, trademarks, service marks, or product names of the Licensor,
5934+
except as required for reasonable and customary use in describing the
5935+
origin of the Work and reproducing the content of the NOTICE file.
5936+
5937+
7. Disclaimer of Warranty. Unless required by applicable law or
5938+
agreed to in writing, Licensor provides the Work (and each
5939+
Contributor provides its Contributions) on an "AS IS" BASIS,
5940+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
5941+
implied, including, without limitation, any warranties or conditions
5942+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
5943+
PARTICULAR PURPOSE. You are solely responsible for determining the
5944+
appropriateness of using or redistributing the Work and assume any
5945+
risks associated with Your exercise of permissions under this License.
5946+
5947+
8. Limitation of Liability. In no event and under no legal theory,
5948+
whether in tort (including negligence), contract, or otherwise,
5949+
unless required by applicable law (such as deliberate and grossly
5950+
negligent acts) or agreed to in writing, shall any Contributor be
5951+
liable to You for damages, including any direct, indirect, special,
5952+
incidental, or consequential damages of any character arising as a
5953+
result of this License or out of the use or inability to use the
5954+
Work (including but not limited to damages for loss of goodwill,
5955+
work stoppage, computer failure or malfunction, or any and all
5956+
other commercial damages or losses), even if such Contributor
5957+
has been advised of the possibility of such damages.
5958+
5959+
9. Accepting Warranty or Additional Liability. While redistributing
5960+
the Work or Derivative Works thereof, You may choose to offer,
5961+
and charge a fee for, acceptance of support, warranty, indemnity,
5962+
or other liability obligations and/or rights consistent with this
5963+
License. However, in accepting such obligations, You may act only
5964+
on Your own behalf and on Your sole responsibility, not on behalf
5965+
of any other Contributor, and only if You agree to indemnify,
5966+
defend, and hold each Contributor harmless for any liability
5967+
incurred by, or claims asserted against, such Contributor by reason
5968+
of your accepting any such warranty or additional liability.
5969+
5970+
END OF TERMS AND CONDITIONS
5971+
5972+
APPENDIX: How to apply the Apache License to your work.
5973+
5974+
To apply the Apache License to your work, attach the following
5975+
boilerplate notice, with the fields enclosed by brackets "[]"
5976+
replaced with your own identifying information. (Don't include
5977+
the brackets!) The text should be enclosed in the appropriate
5978+
comment syntax for the file format. We also recommend that a
5979+
file or class name and description of purpose be included on the
5980+
same "printed page" as the copyright notice for easier
5981+
identification within third-party archives.
5982+
5983+
Copyright [yyyy] [name of copyright owner]
5984+
5985+
Licensed under the Apache License, Version 2.0 (the "License");
5986+
you may not use this file except in compliance with the License.
5987+
You may obtain a copy of the License at
5988+
5989+
http://www.apache.org/licenses/LICENSE-2.0
5990+
5991+
Unless required by applicable law or agreed to in writing, software
5992+
distributed under the License is distributed on an "AS IS" BASIS,
5993+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5994+
See the License for the specific language governing permissions and
5995+
limitations under the License.

cmake/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ option(onnxruntime_USE_QNN "Build with QNN support" OFF)
6868
option(onnxruntime_USE_SNPE "Build with SNPE support" OFF)
6969
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
7070
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
71+
option(onnxruntime_USE_JS "Build with JavaScript implemented kernels support" OFF)
7172
option(onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" ON)
7273
option(onnxruntime_BUILD_CSHARP "Build C# library" OFF)
7374
option(onnxruntime_BUILD_OBJC "Build Objective-C library" OFF)
@@ -655,6 +656,11 @@ if (onnxruntime_USE_NNAPI_BUILTIN)
655656
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_NNAPI_BUILTIN=1)
656657
list(APPEND ONNXRUNTIME_PROVIDER_NAMES nnapi)
657658
endif()
659+
if (onnxruntime_USE_JS)
660+
list(APPEND ORT_PROVIDER_FLAGS -DUSE_JS=1)
661+
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_JS=1)
662+
list(APPEND ONNXRUNTIME_PROVIDER_NAMES js)
663+
endif()
658664
if (onnxruntime_USE_QNN)
659665
list(APPEND ORT_PROVIDER_FLAGS -DUSE_QNN=1)
660666
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_QNN=1)

cmake/onnxruntime_providers.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ endif()
114114
if(onnxruntime_USE_NNAPI_BUILTIN)
115115
set(PROVIDERS_NNAPI onnxruntime_providers_nnapi)
116116
endif()
117+
if(onnxruntime_USE_JS)
118+
set(PROVIDERS_JS onnxruntime_providers_js)
119+
endif()
117120
if(onnxruntime_USE_QNN)
118121
set(PROVIDERS_QNN onnxruntime_providers_qnn)
119122
endif()
@@ -1064,6 +1067,24 @@ if (onnxruntime_USE_NNAPI_BUILTIN)
10641067
endif()
10651068
endif()
10661069

1070+
if (onnxruntime_USE_JS)
1071+
add_compile_definitions(USE_JS=1)
1072+
1073+
file(GLOB_RECURSE onnxruntime_providers_js_cc_srcs
1074+
"${ONNXRUNTIME_ROOT}/core/providers/js/*.h"
1075+
"${ONNXRUNTIME_ROOT}/core/providers/js/*.cc"
1076+
)
1077+
1078+
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_js_cc_srcs})
1079+
onnxruntime_add_static_library(onnxruntime_providers_js ${onnxruntime_providers_js_cc_srcs})
1080+
onnxruntime_add_include_to_target(onnxruntime_providers_js
1081+
onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers Boost::mp11
1082+
)
1083+
1084+
add_dependencies(onnxruntime_providers_js ${onnxruntime_EXTERNAL_DEPENDENCIES})
1085+
1086+
endif()
1087+
10671088
if (onnxruntime_USE_QNN)
10681089
add_compile_definitions(USE_QNN=1)
10691090

cmake/onnxruntime_unittests.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ if(onnxruntime_USE_NNAPI_BUILTIN)
504504
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
505505
endif()
506506

507+
if(onnxruntime_USE_JS)
508+
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_js)
509+
endif()
510+
507511
if(onnxruntime_USE_RKNPU)
508512
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_rknpu)
509513
endif()
@@ -551,6 +555,7 @@ set(ONNXRUNTIME_TEST_LIBS
551555
${onnxruntime_libs}
552556
# CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
553557
${PROVIDERS_NNAPI}
558+
${PROVIDERS_JS}
554559
${PROVIDERS_QNN}
555560
${PROVIDERS_SNPE}
556561
${PROVIDERS_RKNPU}
@@ -604,6 +609,13 @@ if(onnxruntime_USE_NNAPI_BUILTIN)
604609
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_nnapi)
605610
endif()
606611

612+
if(onnxruntime_USE_JS)
613+
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/js/*)
614+
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_js)
615+
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_js)
616+
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_js)
617+
endif()
618+
607619
if(onnxruntime_USE_QNN)
608620
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/qnn/*)
609621
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_qnn)
@@ -839,6 +851,9 @@ if (onnxruntime_BUILD_WEBASSEMBLY)
839851
if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
840852
set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1")
841853
endif()
854+
if (onnxruntime_USE_JS)
855+
set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY LINK_FLAGS " --pre-js \"${ONNXRUNTIME_ROOT}/wasm/js_internal_api.js\"")
856+
endif()
842857
endif()
843858

844859
if (onnxruntime_ENABLE_ATEN)

0 commit comments

Comments
 (0)