Skip to content

Commit

Permalink
webnn: replace DataError with TypeError
Browse files Browse the repository at this point in the history
The spec had been updated to throw TypeError for failed input
validations: webmachinelearning/webnn#589.

This CL replaces the last remaining DataErrors in lstm implementation and triangular wpt.

Bug: 40206287
Change-Id: I73952ce5b407f2df1d9d3b22c0086638d092e811
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5632940
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Austin Sullivan <[email protected]>
Auto-Submit: Jiewei Qian <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1317381}
  • Loading branch information
wacky6 authored and sadym-chromium committed Jul 18, 2024
1 parent 3ed35e6 commit 6a593df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions webnn/validation_tests/lstm.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ const tests = [
]
},
{
name: '[lstm] DataError is expected if hiddenSize equals to zero',
name: '[lstm] TypeError is expected if hiddenSize equals to zero',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
steps: steps,
hiddenSize: 0
},
{
name: '[lstm] DataError is expected if hiddenSize is too large',
name: '[lstm] TypeError is expected if hiddenSize is too large',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
steps: steps,
hiddenSize: 4294967295,
},
{
name: '[lstm] DataError is expected if steps equals to zero',
name: '[lstm] TypeError is expected if steps equals to zero',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
Expand All @@ -138,7 +138,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the data type is not one of the floating point types',
'[lstm] TypeError is expected if the data type is not one of the floating point types',
input: {dataType: 'uint32', dimensions: kValidInputDimensions},
weight: {dataType: 'uint32', dimensions: kValidWeightDimensions},
recurrentWeight:
Expand All @@ -147,7 +147,7 @@ const tests = [
hiddenSize: hiddenSize
},
{
name: '[lstm] DataError is expected if the rank of input is not 3',
name: '[lstm] TypeError is expected if the rank of input is not 3',
input: {dataType: 'float32', dimensions: [steps, batchSize]},
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
Expand All @@ -156,15 +156,15 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if input.dimensions[0] is not equal to steps',
'[lstm] TypeError is expected if input.dimensions[0] is not equal to steps',
input: {dataType: 'float32', dimensions: [1000, batchSize, inputSize]},
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
steps: steps,
hiddenSize: hiddenSize
},
{
name: '[lstm] DataError is expected if the shape of weight is incorrect',
name: '[lstm] TypeError is expected if the shape of weight is incorrect',
input: kExampleInputDescriptor,
weight: {
dataType: 'float32',
Expand All @@ -176,7 +176,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the rank of recurrentWeight is not 3',
'[lstm] TypeError is expected if the rank of recurrentWeight is not 3',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight:
Expand All @@ -186,7 +186,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the size of options.activations is not 3',
'[lstm] TypeError is expected if the size of options.activations is not 3',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
Expand All @@ -195,7 +195,7 @@ const tests = [
options: {activations: ['sigmoid', 'tanh']}
},
{
name: '[lstm] DataError is expected if the rank of options.bias is not 2',
name: '[lstm] TypeError is expected if the rank of options.bias is not 2',
input: {dataType: 'float16', dimensions: kValidInputDimensions},
weight: {dataType: 'float16', dimensions: kValidWeightDimensions},
recurrentWeight:
Expand All @@ -206,7 +206,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the shape of options.recurrentBias.dimensions is incorrect',
'[lstm] TypeError is expected if the shape of options.recurrentBias.dimensions is incorrect',
input: {dataType: 'float16', dimensions: kValidInputDimensions},
weight: {dataType: 'float16', dimensions: kValidWeightDimensions},
recurrentWeight:
Expand All @@ -219,7 +219,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the dataType of options.peepholeWeight is incorrect',
'[lstm] TypeError is expected if the dataType of options.peepholeWeight is incorrect',
input: {dataType: 'float16', dimensions: kValidInputDimensions},
weight: {dataType: 'float16', dimensions: kValidWeightDimensions},
recurrentWeight:
Expand All @@ -233,7 +233,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the dataType of options.initialHiddenState is incorrect',
'[lstm] TypeError is expected if the dataType of options.initialHiddenState is incorrect',
input: {dataType: 'float16', dimensions: kValidInputDimensions},
weight: {dataType: 'float16', dimensions: kValidWeightDimensions},
recurrentWeight:
Expand All @@ -249,7 +249,7 @@ const tests = [
},
{
name:
'[lstm] DataError is expected if the shape of options.initialCellState is incorrect',
'[lstm] TypeError is expected if the shape of options.initialCellState is incorrect',
input: kExampleInputDescriptor,
weight: kExampleWeightDescriptor,
recurrentWeight: kExampleRecurrentWeightDescriptor,
Expand Down Expand Up @@ -333,8 +333,8 @@ tests.forEach(
assert_array_equals(outputs[i].shape(), test.outputs[i].dimensions);
}
} else {
assert_throws_dom(
'DataError',
assert_throws_js(
TypeError,
() => builder.lstm(
input, weight, recurrentWeight, test.steps, test.hiddenSize,
options));
Expand Down
2 changes: 1 addition & 1 deletion webnn/validation_tests/triangular.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ promise_test(async t => {
assert_throws_js(TypeError, () => builder.triangular(input));
}
}
}, "[triangular] DataError is expected if input's rank is less than 2");
}, "[triangular] TypeError is expected if input's rank is less than 2");

validateInputFromAnotherBuilder('triangular');

0 comments on commit 6a593df

Please sign in to comment.