Skip to content
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

[webnn] Add float32 tests for WebNN API where op #43558

Merged
merged 1 commit into from
Dec 13, 2023
Merged
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
10 changes: 10 additions & 0 deletions webnn/gpu/where.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// META: title=test WebNN API where operation
// META: global=window,dedicatedworker
// META: script=../resources/utils.js
// META: timeout=long

'use strict';

// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-where

testWebNNOperation('where', buildWhere, 'gpu');
10 changes: 10 additions & 0 deletions webnn/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ const PrecisionMetrics = {
squeeze: {ULP: {float32: 0, float16: 0}},
tanh: {ATOL: {float32: 1/1024, float16: 1/512}},
transpose: {ULP: {float32: 0, float16: 0}},
where: {ULP: {float32: 0, float16: 0}},
};

/**
Expand Down Expand Up @@ -691,6 +692,15 @@ const buildSplit = (operationName, builder, resources) => {
return namedOutputOperand;
};

const buildWhere = (operationName, builder, resources) => {
// MLOperand where(MLOperand condition, MLOperand trueValues, MLOperand falseValues);
const namedOutputOperand = {};
const [conditionOperand, trueValuesOperand, falseValuesOperand] = createMultiInputOperands(builder, resources);
// invoke builder.where()
namedOutputOperand[resources.expected.name] = builder[operationName](conditionOperand, trueValuesOperand, falseValuesOperand);
return namedOutputOperand;
};

/**
* Build a graph.
* @param {String} operationName - An operation name
Expand Down
10 changes: 10 additions & 0 deletions webnn/where.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// META: title=test WebNN API where operation
// META: global=window,dedicatedworker
// META: script=./resources/utils.js
// META: timeout=long

'use strict';

// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-where

testWebNNOperation('where', buildWhere);