Skip to content

Commit

Permalink
Test different layout for CPU backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Aug 6, 2024
1 parent 897226c commit 5019005
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ export function getUrlParams() {
}
}

return [numRuns, powerPreference, numThreads];
let new_layout = 'nchw';

Check failure on line 345 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

Identifier 'new_layout' is not in camel case

Check failure on line 345 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

Identifier 'new_layout' is not in camel case
if (['nhwc', 'nchw'].includes(params.get('layout'))) {
new_layout = params.get('layout');

Check failure on line 347 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

Identifier 'new_layout' is not in camel case

Check failure on line 347 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

Identifier 'new_layout' is not in camel case
}

return [numRuns, powerPreference, numThreads, new_layout];

Check failure on line 350 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

Identifier 'new_layout' is not in camel case

Check failure on line 350 in common/utils.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

Identifier 'new_layout' is not in camel case
}

// Set backend for using WebNN-polyfill or WebNN
Expand Down
5 changes: 3 additions & 2 deletions image_classification/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $('#backendBtns .btn').on('change', async (e) => {
await stopCamRender();
}
const backendId = $(e.target).attr('id');
layout = utils.getDefaultLayout(backendId);
// layout = utils.getDefaultLayout(backendId);
[backend, deviceType] = backendId.split('_');
// Only show the supported models for each deviceType. Now fp16 nchw models
// are only supported on gpu/npu.
Expand Down Expand Up @@ -313,7 +313,8 @@ async function main() {
ui.handleClick(disabledSelectors, true);
if (isFirstTimeLoad) $('#hint').hide();
let start;
const [numRuns, powerPreference, numThreads] = utils.getUrlParams();
const [numRuns, powerPreference, numThreads, new_layout] = utils.getUrlParams();

Check failure on line 316 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

This line has a length of 84. Maximum allowed is 80

Check failure on line 316 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

Identifier 'new_layout' is not in camel case

Check failure on line 316 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

This line has a length of 84. Maximum allowed is 80

Check failure on line 316 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

Identifier 'new_layout' is not in camel case
layout = new_layout;

Check failure on line 317 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (ubuntu-latest)

Identifier 'new_layout' is not in camel case

Check failure on line 317 in image_classification/main.js

View workflow job for this annotation

GitHub Actions / job (macos-latest)

Identifier 'new_layout' is not in camel case

// Only do load() and build() when model first time loads,
// there's new model choosed, backend changed or device changed
Expand Down

0 comments on commit 5019005

Please sign in to comment.