Comments (8)
@KTibow thank you for reporting this issue. I am not very familiar with Vite. I want to understand more details about the problem.
The new version of ORT Web uses dynamic import to load file ort-wasm-simd-threaded.jsep.mjs
. Do you mean that Vite does not support dynamic import, or it is not recommended to use dynamic import in Vite?
from onnxruntime.
The import function is supported in Vite to some degree.
If a static argument is passed, or a directory with a templated file, Vite can bundle the code. However, if the argument is dynamic, Vite won't know which code to bundle and won't update the function to work.
There are other ways that can help with dynamic file importing, but regardless, the directory of the file has to be known at build time in order for bundling to work.
* technicality: Vite isn't a bundler in itself, it uses Rollup, esbuild, and soon a rewrite of Rollup to bundle the code
* just writing this down has made me realize that this might not be a simple solution as I wrote in the original post, it'll probably require some consideration
from onnxruntime.
The fundamental reason of why I uses dynamic import is becaues Emscripten does not support to generate both UMD/ESM glue for a Wasm target - you have to choose either. This means I have the following options:
- build both
ort-wasm-simd-threaded-umd.wasm
+ort-wasm-simd-threaded-umd.js
andort-wasm-simd-threaded-esm.wasm
+ort-wasm-simd-threaded-esm.mjs
- only build one target, and use it in both ESM/UMD.
The option (1) not only doubled the package size for technically unnecessary reason, but also makes the deployment more complicated. A mismatch will not work and adds quite steps into troubleshooting.
I am currently using (2) to build ESM and import it in both UMD/ESM bundle.
from onnxruntime.
If a static argument is passed, or a directory with a templated file, Vite can bundle the code. However, if the argument is dynamic, Vite won't know which code to bundle and won't update the function to work.
Based on the reason above, I expect the bundler to leave the dynamic import as-is, to keep the dynamic import behavior. rollup
( the underlying bundler) seems to support it correctly, but it seems Vite does not expect any .js/.mjs files to serve directly as assets.
from onnxruntime.
rollup seems to support it correctly
I'm a bit confused by how this would be possible. I have a suspicion, but I'd like to see the file structure of the bundled files so I can confirm/deny it.
from onnxruntime.
https://github.com/microsoft/onnxruntime/tree/main/js/web/test/e2e
The E2E folder contains bundler test for webpack, rollup and percel
from onnxruntime.
@KTibow you can alternatively import ORT Web in ESM. In latest main branch, dynamic import is disabled by default when you consume ORT Web as ESModule.
from onnxruntime.
Works in my tests 👍
from onnxruntime.
Related Issues (20)
- [Performance] Multiple Sessions on Same GPU is very slow
- [Models larger than 2GB :(] Specify mid-graph.output after initializing InferenceSession HOT 2
- [Error] [ONNXRuntimeError] : 1 : FAIL : CUDA failure 3: initialization error HOT 4
- [Build] long paths in NuGet package breaking build on Windows
- [Feature Request] Missing optimization of DequantizeLinear ∘ Flatten ∘ QuantizeLinear?
- Missing onnxruntime_perf_test.exe in Release Assets (or what actually is "Build Drop"?) HOT 2
- [Build]: cmake', '--build', '/temp/liz/onnxruntime/build/Linux/RelWithDebInfo', '--config', 'RelWithDebInfo', '--', '-j64'] HOT 1
- [Feature Request] Request grid_sample 5D support 🌟 HOT 1
- [Build][Bug] The compiler doesn't support BFLOAT16!!! HOT 2
- [WebGPU] `Error: [WebGPU] Kernel "[MaxPool] /sincnet/pool1d.0/MaxPool" failed. Error: length of specified kernel shapes should be 2 less than length of input dimensions` HOT 1
- Error Instantiating EmbeddingModel with ONNX Model intfloat/multilingual-e5-large HOT 1
- [Documentation] Community blog post contribution HOT 1
- [ARM][CPU] Unit test and onnx_runtime_perf test gives cpuinfo error for new Windows ARM chips HOT 2
- [Feature Request] Mark as negative tests for minimal CUDA build
- New restricted asymmetric quantization mode in QDQ mode with zero_point restricted to either 128 or 0
- Trilu op still not work with INT32 input HOT 2
- [WebNN EP] Support int64 output data type for CoreML backend HOT 1
- [Web] where is the demo of object detection on web HOT 1
- LNK2019: unresolved external symbol OrtGetApiBase HOT 1
- Multi-threaded GPU inferencing failing with whisper-small: Non-zero status code returned while running DecoderMaskedMultiHeadAttention node HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onnxruntime.