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: Remove some activations not usable with recurrent ops #46678

Merged
merged 1 commit into from
Jun 11, 2024
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
20 changes: 1 addition & 19 deletions webnn/validation_tests/clamp.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

validateInputFromAnotherBuilder('clamp');

validateUnaryOperation(
'clamp', allWebNNOperandDataTypes, /*alsoBuildActivation=*/ true);
validateUnaryOperation('clamp', allWebNNOperandDataTypes);

promise_test(async t => {
const options = {minValue: 1.0, maxValue: 3.0};
Expand All @@ -27,11 +26,6 @@ promise_test(async t => {
assert_array_equals(output.shape(), [1, 2, 3, 4]);
}, '[clamp] Test building an operator with options.minValue == options.maxValue');

promise_test(async t => {
const options = {minValue: 2.0};
builder.clamp(options);
}, '[clamp] Test building an activation with options');

promise_test(async t => {
const options = {minValue: 3.0, maxValue: 1.0};
const input =
Expand All @@ -46,15 +40,3 @@ promise_test(async t => {
const input = builder.input('input', {dataType: 'float16', dimensions: []});
assert_throws_js(TypeError, () => builder.clamp(input, options));
}, '[clamp] Throw if options.minValue is -Infinity when building an operator');

promise_test(async t => {
const options = {minValue: 2.0, maxValue: -1.0};
assert_throws_js(TypeError, () => builder.clamp(options));
}, '[clamp] Throw if options.minValue > options.maxValue when building an activation');

// To be removed once NaN `maxValue` is allowed. Tracked in
// https://github.com/webmachinelearning/webnn/pull/647.
promise_test(async t => {
const options = {maxValue: NaN};
assert_throws_js(TypeError, () => builder.clamp(options));
}, '[clamp] Throw if options.maxValue is NaN when building an activation');
4 changes: 2 additions & 2 deletions webnn/validation_tests/gru.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ multi_builder_test(async (t, builder, otherBuilder) => {
}, '[gru] throw if initialHiddenState option is from another builder');

multi_builder_test(async (t, builder, otherBuilder) => {
const activation = builder.clamp();
const activationFromOtherBuilder = otherBuilder.clamp();
const activation = builder.relu();
const activationFromOtherBuilder = otherBuilder.relu();
const options = {activations: [activation, activationFromOtherBuilder]};

const input = builder.input('input', kExampleInputDescriptor);
Expand Down
4 changes: 2 additions & 2 deletions webnn/validation_tests/gruCell.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ multi_builder_test(async (t, builder, otherBuilder) => {
}, '[gruCell] throw if recurrentBias option is from another builder');

multi_builder_test(async (t, builder, otherBuilder) => {
const activation = builder.clamp();
const activationFromOtherBuilder = otherBuilder.clamp();
const activation = builder.relu();
const activationFromOtherBuilder = otherBuilder.relu();
const options = {activations: [activation, activationFromOtherBuilder]};

const input = builder.input('input', kExampleInputDescriptor);
Expand Down
4 changes: 2 additions & 2 deletions webnn/validation_tests/lstm.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ multi_builder_test(async (t, builder, otherBuilder) => {
}, '[lstm] throw if initialCellState option is from another builder');

multi_builder_test(async (t, builder, otherBuilder) => {
const activation = builder.clamp();
const activationFromOtherBuilder = otherBuilder.clamp();
const activation = builder.relu();
const activationFromOtherBuilder = otherBuilder.relu();
const options = {activations: [activation, activationFromOtherBuilder]};

const input = builder.input('input', kExampleInputDescriptor);
Expand Down
4 changes: 2 additions & 2 deletions webnn/validation_tests/lstmCell.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ multi_builder_test(async (t, builder, otherBuilder) => {
}, '[lstmCell] throw if peepholeWeight option is from another builder');

multi_builder_test(async (t, builder, otherBuilder) => {
const activation = builder.clamp();
const activationFromOtherBuilder = otherBuilder.clamp();
const activation = builder.relu();
const activationFromOtherBuilder = otherBuilder.relu();
const options = {activations: [activation, activationFromOtherBuilder]};

const input = builder.input('input', kExampleInputDescriptor);
Expand Down