mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
### Description This PR adds a new option `ort.env.wasm.wasmBinary`, which allows user to set to a buffer containing preload .wasm file content. This PR should resolve the problem from latest discussion in #20876.
22 lines
734 B
JavaScript
22 lines
734 B
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
'use strict';
|
|
|
|
const documentUrl = document.currentScript.src;
|
|
|
|
it('Browser E2E testing - WebAssembly backend', async function() {
|
|
// preload .wasm file binary
|
|
const wasmUrl = new URL('./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm', documentUrl).href;
|
|
const response = await fetch(wasmUrl);
|
|
|
|
// make sure the .wasm file is loaded successfully
|
|
assert(response.ok);
|
|
assert(response.headers.get('Content-Type') === 'application/wasm');
|
|
|
|
// override wasm binary
|
|
const binary = await response.arrayBuffer();
|
|
ort.env.wasm.wasmBinary = binary;
|
|
|
|
await testFunction(ort, {executionProviders: ['wasm']});
|
|
});
|