mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-22 22:01:08 +00:00
* 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
* Enable linking in exception throwing support library when build onnxruntime wasm. (#8973)
* Enable linking in exception throwing support library when build onnxruntime webassembly containing onnxruntime-extensions.
* Add flag in build.py to enable linking exceptions throwing library.
* Update onnxruntime-extensions document and bind custom_ops build flag with use_extensions.
* Update doc.
* Update cgmanifest.json.
Co-authored-by: Zuwei Zhao <zuzhao@microsoft.com>
* Remove document text from error message in a couple of ops (#9003)
* do not add pkg wheel entry to the index html file if it already exists (#9004)
* do not add pkg wheel entry to the index html file if it already exists
* [js/web] fix ort web e2e test (#9025)
* Fix cmake POWER10 detection
Recent commit 60c98a8 changed variable mlas_common_srcs which affects
POWER10 detection.
* Fix Where op type reduction processing (#9033)
* Update type reduction script to track Where Op's second input type.
* Clean up op_kernel_type_control.h includes.
* Use more maintainable include.
* Fix ROCm wheels CI pipeline break by installing latest protobuf from source (#9047)
* install protobuf from source
* fix rm command in Dockerfile
* fix options on rm command
* fix cd into protobuf source directory
* try again
* remove strip step
* debug list the files
* ls on /usr
* more debug
* more debug
* adjust LD_LIBRARY_PATH
* try remove protobuf before ORT build
* [js/web] a bugfix and add tests for wasm proxy worker (#9048)
* [js/web] add tests for wasm proxy worker
* fix script src override
* Set onnxruntime_DISABLE_RTTI to default OFF (#9049)
Co-authored-by: Du Li <duli1@microsoft.com>
Co-authored-by: Zuwei Zhao <4123666+Zuwei-Zhao@users.noreply.github.com>
Co-authored-by: Zuwei Zhao <zuzhao@microsoft.com>
Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com>
Co-authored-by: liqun Fu <liqfu@microsoft.com>
Co-authored-by: Yulong Wang <yulongw@microsoft.com>
Co-authored-by: Rajalakshmi Srinivasaraghavan <rajis@linux.ibm.com>
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
Co-authored-by: Suffian Khan <sukha@microsoft.com>
Co-authored-by: Changming Sun <chasun@microsoft.com>
128 lines
5.5 KiB
JavaScript
128 lines
5.5 KiB
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
const globby = require('globby');
|
|
const { spawn } = require('child_process');
|
|
const startServer = require('./simple-http-server');
|
|
|
|
// copy whole folder to out-side of <ORT_ROOT>/js/ because we need to test in a folder that no `package.json` file
|
|
// exists in its parent folder.
|
|
// here we use <ORT_ROOT>/build/js/e2e/ for the test
|
|
|
|
const TEST_E2E_SRC_FOLDER = __dirname;
|
|
const JS_ROOT_FOLDER = path.resolve(__dirname, '../../..');
|
|
const TEST_E2E_RUN_FOLDER = path.resolve(JS_ROOT_FOLDER, '../build/js/e2e');
|
|
const NPM_CACHE_FOLDER = path.resolve(TEST_E2E_RUN_FOLDER, '../npm_cache');
|
|
const CHROME_USER_DATA_FOLDER = path.resolve(TEST_E2E_RUN_FOLDER, '../user_data');
|
|
fs.emptyDirSync(TEST_E2E_RUN_FOLDER);
|
|
fs.emptyDirSync(NPM_CACHE_FOLDER);
|
|
fs.emptyDirSync(CHROME_USER_DATA_FOLDER);
|
|
fs.copySync(TEST_E2E_SRC_FOLDER, TEST_E2E_RUN_FOLDER);
|
|
|
|
// find packed package
|
|
|
|
const ORT_COMMON_FOLDER = path.resolve(JS_ROOT_FOLDER, 'common');
|
|
const ORT_COMMON_PACKED_FILEPATH_CANDIDATES = globby.sync('onnxruntime-common-*.tgz', { cwd: ORT_COMMON_FOLDER });
|
|
if (ORT_COMMON_PACKED_FILEPATH_CANDIDATES.length !== 1) {
|
|
throw new Error('cannot find exactly single package for onnxruntime-common.');
|
|
}
|
|
const ORT_COMMON_PACKED_FILEPATH = path.resolve(ORT_COMMON_FOLDER, ORT_COMMON_PACKED_FILEPATH_CANDIDATES[0]);
|
|
|
|
const ORT_WEB_FOLDER = path.resolve(JS_ROOT_FOLDER, 'web');
|
|
const ORT_WEB_PACKED_FILEPATH_CANDIDATES = globby.sync('onnxruntime-web-*.tgz', { cwd: ORT_WEB_FOLDER });
|
|
if (ORT_WEB_PACKED_FILEPATH_CANDIDATES.length !== 1) {
|
|
throw new Error('cannot find exactly single package for onnxruntime-web.');
|
|
}
|
|
const ORT_WEB_PACKED_FILEPATH = path.resolve(ORT_WEB_FOLDER, ORT_WEB_PACKED_FILEPATH_CANDIDATES[0]);
|
|
|
|
// we start here:
|
|
|
|
async function main() {
|
|
// install dev dependencies
|
|
await runInShell(`npm install"`);
|
|
|
|
// npm install with "--cache" to install packed packages with an empty cache folder
|
|
await runInShell(`npm install --cache "${NPM_CACHE_FOLDER}" "${ORT_COMMON_PACKED_FILEPATH}" "${ORT_WEB_PACKED_FILEPATH}"`);
|
|
|
|
// prepare .wasm files for path override testing
|
|
prepareWasmPathOverrideFiles();
|
|
|
|
// test case run in Node.js
|
|
await testAllNodejsCases();
|
|
|
|
// test cases with self-host (ort hosted in same origin)
|
|
await testAllBrowserCases({ hostInKarma: true });
|
|
|
|
// test cases without self-host (ort hosted in same origin)
|
|
startServer(path.resolve(TEST_E2E_RUN_FOLDER, 'node_modules', 'onnxruntime-web'));
|
|
await testAllBrowserCases({ hostInKarma: false });
|
|
|
|
// no error occurs, exit with code 0
|
|
process.exit(0);
|
|
}
|
|
|
|
function prepareWasmPathOverrideFiles() {
|
|
const folder = path.join(TEST_E2E_RUN_FOLDER, 'test-wasm-path-override');
|
|
const sourceFile = path.join(TEST_E2E_RUN_FOLDER, 'node_modules', 'onnxruntime-web', 'dist', 'ort-wasm.wasm');
|
|
fs.emptyDirSync(folder);
|
|
fs.copyFileSync(sourceFile, path.join(folder, 'ort-wasm.wasm'));
|
|
fs.copyFileSync(sourceFile, path.join(folder, 'renamed.wasm'));
|
|
}
|
|
|
|
async function testAllNodejsCases() {
|
|
await runInShell('node ./node_modules/mocha/bin/mocha ./node-test-main-no-threads.js');
|
|
await runInShell('node ./node_modules/mocha/bin/mocha ./node-test-main.js');
|
|
await runInShell('node --experimental-wasm-threads --experimental-wasm-bulk-memory ./node_modules/mocha/bin/mocha ./node-test-main-no-threads.js');
|
|
await runInShell('node --experimental-wasm-threads --experimental-wasm-bulk-memory ./node_modules/mocha/bin/mocha ./node-test-main.js');
|
|
await runInShell('node ./node_modules/mocha/bin/mocha ./node-test-wasm-path-override-filename.js');
|
|
await runInShell('node ./node_modules/mocha/bin/mocha ./node-test-wasm-path-override-prefix.js');
|
|
}
|
|
|
|
async function testAllBrowserCases({ hostInKarma }) {
|
|
await runKarma({ hostInKarma, main: './browser-test-webgl.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm-no-threads.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm-proxy.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm-no-threads-proxy.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm-path-override-filename.js', browser: 'Chrome_default' });
|
|
await runKarma({ hostInKarma, main: './browser-test-wasm-path-override-prefix.js', browser: 'Chrome_default' });
|
|
}
|
|
|
|
async function runKarma({ hostInKarma, main, browser }) {
|
|
const selfHostFlag = hostInKarma ? '--self-host' : '';
|
|
await runInShell(
|
|
`npx karma start --single-run --browsers ${browser} ${selfHostFlag} --test-main=${main} --user-data=${CHROME_USER_DATA_FOLDER}`);
|
|
}
|
|
|
|
async function runInShell(cmd) {
|
|
console.log('===============================================================');
|
|
console.log(' Running command in shell:');
|
|
console.log(' > ' + cmd);
|
|
console.log('===============================================================');
|
|
let complete = false;
|
|
const childProcess = spawn(cmd, { shell: true, stdio: 'inherit', cwd: TEST_E2E_RUN_FOLDER });
|
|
childProcess.on('close', function (code) {
|
|
if (code !== 0) {
|
|
process.exit(code);
|
|
} else {
|
|
complete = true;
|
|
}
|
|
});
|
|
while (!complete) {
|
|
await delay(100);
|
|
}
|
|
}
|
|
|
|
async function delay(ms) {
|
|
return new Promise(function (resolve) {
|
|
setTimeout(function () {
|
|
resolve();
|
|
}, ms);
|
|
});
|
|
}
|
|
|
|
main();
|