Skip to content

Support multiple backends #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ out/
.vscode/
env.json
package-lock.json
config.json
config*.json
9 changes: 5 additions & 4 deletions generate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ program
.default(["cpu", "gpu", "npu"])
)
.addOption(new Option("-e, --backend <backend>", "The backend to use").choices(["ort", "tflite"]).default("ort"))
.action(async ({ devices, browser, backend }) => {
.option("-o, --output <path>", "The output config file path", "config.json")
.action(async ({ devices, browser, backend, output }) => {
if (process.platform === "linux" && browser === "edge_canary") {
console.error("edge_canary is not available on linux.");
return;
Expand All @@ -313,7 +314,7 @@ program
devices.splice(devices.indexOf("npu"), 1);
}

const config = { browser, ...filterSamplesWithDevices(ORIGINAL_CONFIG, devices) };
const config = { backend, browser, ...filterSamplesWithDevices(ORIGINAL_CONFIG, devices) };
if (backend === "ort") {
config.browserArgs.push("--enable-features=WebMachineLearningNeuralNetwork,WebNNOnnxRuntime");
} else if (backend === "tflite") {
Expand All @@ -323,7 +324,7 @@ program
);
}

fs.writeFileSync("config.json", JSON.stringify(config, null, 2));
console.log(`Generated config.json for ${browser} with ${backend} backend on ${devices.join("-")}`);
fs.writeFileSync(output, JSON.stringify(config, null, 2));
console.log(`Generated ${output} for ${browser} with ${backend} backend on ${devices.join("-")}`);
})
.parse();
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ program
program.action(async ({ config: configPath, filters, browserDir, userDataDir }) => {
try {
const config = require(path.resolve(process.cwd(), configPath));
console.log(`Using config file: ${configPath}`);

if (filters === true) {
console.log("Available filters:");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async function report(results) {
}
const hostname = env.hostname || os.hostname();
const reportTime = util.getTimestamp(true);
let subject = `[Sample Test][${results.deviceInfo.browser}] ${hostname} ${reportTime}`;
let subject = `[Sample Test][${results.deviceInfo.browser}][${results.deviceInfo.backend}] ${hostname} ${reportTime}`;

try {
await sendMail(subject, await renderResultsAsHTML(results), [
Expand Down
16 changes: 9 additions & 7 deletions src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@ async function getNPUInfo() {

// get device info
async function getDeviceInfo(config) {
let deviceInfo = {};
deviceInfo["hostname"] = config["hostname"] ? config["hostname"] : os.hostname();
deviceInfo.platform = os.platform();
deviceInfo["samplesUrl"] = config["samplesBasicUrl"];
deviceInfo["developerPreviewUrl"] = config["developerPreviewBasicUrl"];
deviceInfo["browser"] = config["browser"];
deviceInfo["browserArgs"] = config["browserArgs"];
let deviceInfo = {
hostname: config.hostname || os.hostname(),
platform: os.platform(),
samplesUrl: config.samplesBasicUrl,
developerPreviewUrl: config.developerPreviewBasicUrl,
backend: config.backend,
browser: config.browser,
browserArgs: config.browserArgs
};
const { browserPath, userDataDir } = getBrowserPath(config);
deviceInfo["browserPath"] = browserPath;

Expand Down