Skip to content

Commit

Permalink
Update webnn delegate for selfie segmentation sample (#187)
Browse files Browse the repository at this point in the history
- Update deviceType enum
- Add a duplicate entry to support new dataType
- Support WebNN numThreads option
  • Loading branch information
Honry authored Nov 3, 2023
1 parent b138e20 commit a78d45e
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions selfie_segmentation/builtin_delegate_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ onmessage = async (message) => {
numThreads: 1,
enableWebNNDelegate: message.data.enableWebNNDelegate,
webNNDevicePreference: parseInt(message.data.webNNDevicePreference),
webNNNumThreads: parseInt(message.data.webNNNumThreads),
},
);

Expand Down
2 changes: 2 additions & 0 deletions selfie_segmentation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export async function main() {
ui.handleClick(disabledSelectors, true);
if (isFirstTimeLoad) $('#hint').hide();
const numRuns = utils.getUrlParams()[0];
const numThreads = utils.getUrlParams()[2];
// Only do load() when model first time loads and
// there's new model or delegate choosed
if (isFirstTimeLoad || modelChanged) {
Expand All @@ -223,6 +224,7 @@ export async function main() {
modelPath: modelConfigs[modelName].modelPath,
enableWebNNDelegate: enableWebnnDelegate,
webNNDevicePreference: 0,
webNNNumThreads: numThreads,
};
loadTime = await postAndListenMessage(options);
console.log(` done in ${loadTime} ms.`);
Expand Down

Large diffs are not rendered by default.

Binary file modified selfie_segmentation/tflite-support/tflite_model_runner_cc.wasm
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file modified selfie_segmentation/tflite_model_runner_cc_simd.wasm
Binary file not shown.

0 comments on commit a78d45e

Please sign in to comment.