Skip to content

Commit

Permalink
webnn: add wpt for bidirectional lstm
Browse files Browse the repository at this point in the history
Fixes some minor bugs with CoreML bidrection implementation.

Also adjusted ULP for this complex op to 3, this is same as gru.

Bug: 360052663
Change-Id: Ie15ab15a359be70e219fd61ee0d3a3fea21f3405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6103076
Commit-Queue: Phillis Tang <phillis@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1399398}
  • Loading branch information
philloooo authored and chromium-wpt-export-bot committed Dec 20, 2024
1 parent 6b2239d commit 482f155
Showing 1 changed file with 85 additions and 1 deletion.
86 changes: 85 additions & 1 deletion webnn/conformance_tests/lstm.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@


const getLstmPrecisionTolerance = (graphResources) => {
const toleranceValueDict = {float32: 1, float16: 1};
const toleranceValueDict = {float32: 3, float16: 3};
const expectedDataType =
graphResources
.expectedOutputs[Object.keys(graphResources.expectedOutputs)[0]]
Expand Down Expand Up @@ -866,6 +866,90 @@ const lstmTests = [
}
}
},
{
'name': 'lstm float32 tensors steps=2 with bidirections',
'graph': {
'inputs': {
'lstmInput': {
'data': [1, 2, 2, 1, 3, 4, 1, 2],
'descriptor': {shape: [2, 2, 2], dataType: 'float32'}
},
'lstmWeight': {
'data': [
1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2,
1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2, 1, -1, 2, -2
],
'descriptor': {shape: [2, 8, 2], dataType: 'float32'},
'constant': true
},
'lstmRecurrentWeight': {
'data': [
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
],
'descriptor': {shape: [2, 8, 2], dataType: 'float32'},
'constant': true
},
'lstmBias': {
'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],
'descriptor': {shape: [2, 8], dataType: 'float32'},
'constant': true
},
'lstmRecurrentBias': {
'data': [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],
'descriptor': {shape: [2, 8], dataType: 'float32'},
'constant': true
}
},
'operators': [{
'name': 'lstm',
'arguments': [
{'input': 'lstmInput'}, {'weight': 'lstmWeight'},
{'recurrentWeight': 'lstmRecurrentWeight'}, {'steps': 2},
{'hiddenSize': 2}, {
'options': {
'bias': 'lstmBias',
'recurrentBias': 'lstmRecurrentBias',
'returnSequence': true,
'direction': 'both',
'layout': 'iofg'
}
}
],
'outputs': ['lstmOutput1', 'lstmOutput2', 'lstmOutput3']
}],
'expectedOutputs': {
'lstmOutput1': {
'data': [
0.5764073133468628, 0.8236227035522461, 0.6612355709075928,
0.8442635536193848, 0.5764073133468628, 0.8236227035522461,
0.8635294437408447, 0.9491351246833801
],
'descriptor': {shape: [2, 2, 2], dataType: 'float32'}
},
'lstmOutput2': {
'data': [
1.0171456336975098, 1.6205494403839111, 1.3388464450836182,
1.7642604112625122, 1.0171456336975098, 1.6205494403839111,
1.4856269359588623, 1.8449554443359375
],
'descriptor': {shape: [2, 2, 2], dataType: 'float32'}
},
'lstmOutput3': {
'data': [
0.3696063756942749, 0.6082833409309387, 0.7037754058837891,
0.7586681246757507, 0.5764073133468628, 0.8236227035522461,
0.8635294437408447, 0.9491351246833801, 0.5764073133468628,
0.8236227035522461, 0.6612355709075928, 0.8442635536193848,
0.3696063756942749, 0.6082833409309387, 0.3696063756942749,
0.6082833409309387
],
'descriptor': {shape: [2, 2, 2, 2], dataType: 'float32'}
}
}
}
},
{
'name':
'lstm float16 tensors steps=1 with options.bias, options.recurrentBias',
Expand Down

0 comments on commit 482f155

Please sign in to comment.