Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

// META: title=test WebNN API matmul operation
// META: global=window,dedicatedworker
// META: variant=?cpu
// META: variant=?gpu
// META: variant=?npu
// META: script=../resources/utils.js
// META: timeout=long
'use strict';
// Compute the matrix product of two input tensors.
// MLOperand matmul(MLOperand a, MLOperand b);
const getMatmulPrecisionTolerance = (graphResources) => {
const args = graphResources.operators[0].arguments;
const shapeA =
graphResources.inputs[args[0][Object.keys(args[0])[0]]].descriptor.shape;
const tolerance = shapeA[shapeA.length - 1] * 2;
const toleranceValueDict = {float32: tolerance, float16: tolerance};
const expectedDataType =
getExpectedDataTypeOfSingleOutput(graphResources.expectedOutputs);
return {metricType: 'ULP', value: toleranceValueDict[expectedDataType]};
};
const matmulTests = [
{
'name': 'matmul float32 2D and 2D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
10.43066120147705, 24.467519760131836, 55.887577056884766,
3.2410826683044434, 87.58891296386719, 22.40154457092285,
79.85144805908203, 99.64449310302734, 24.740541458129883,
65.9624252319336, 38.136077880859375, 87.11140441894531
],
'descriptor': {shape: [3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
88.1700439453125, 78.4012680053711, 14.819003105163574,
3.6923038959503174, 45.906429290771484, 43.083919525146484,
47.199466705322266, 60.92521667480469, 8.162760734558105,
20.333263397216797, 20.438398361206055, 27.0194091796875,
15.601424217224121, 87.46969604492188, 65.79554748535156,
69.31697082519531, 31.984439849853516, 12.291812896728516,
13.304834365844727, 85.26705169677734
],
'descriptor': {shape: [4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
3340.7431640625, 3586.344482421875, 2557.025634765625,
5169.8271484375, 4929.85009765625, 17226.955078125, 13269.03515625,
5133.4072265625, 8816.5986328125, 18226.65234375, 11841.033203125,
8869.705078125, 6051.1396484375, 5124.5390625, 12413.8984375
],
'descriptor': {shape: [3, 5], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 3D and 3D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
56.46701431274414, 99.86045837402344, 71.054931640625,
32.454383850097656, 17.310747146606445, 2.586275100708008,
92.31499481201172, 96.9758529663086, 26.472131729125977,
77.67031860351562, 29.278789520263672, 82.12142181396484,
89.89308166503906, 82.49795532226562, 64.36865997314453,
23.75928497314453, 6.670266628265381, 81.55583190917969,
16.142963409423828, 57.45134735107422, 26.826417922973633,
85.02970123291016, 36.1988639831543, 89.60960388183594
],
'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
70.38780212402344, 25.48917579650879, 28.254196166992188,
84.5148696899414, 58.873416900634766, 46.252838134765625,
24.897335052490234, 44.0944938659668, 51.86564636230469,
1.123237133026123, 4.187554836273193, 71.24649810791016,
16.034526824951172, 23.677297592163086, 61.27727508544922,
65.15946197509766, 58.39249801635742, 70.12741088867188,
9.11972713470459, 24.179977416992188, 84.4263687133789,
78.55551147460938, 38.48297119140625, 80.6541519165039,
57.152122497558594, 46.109710693359375, 28.41227912902832,
90.92566680908203, 94.66068267822266, 61.77287673950195,
60.324859619140625, 70.97433471679688, 10.631051063537598,
55.61628341674805, 35.052310943603516, 22.12839126586914,
38.19757843017578, 78.17564392089844, 62.57684326171875,
88.35256958007812
],
'descriptor': {shape: [2, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
11005.6748046875, 10883.064453125, 9414.0009765625,
11929.9931640625, 8575.3720703125, 8043.556640625,
12745.41015625, 8884.0341796875, 4667.3173828125,
9023.7333984375, 10929.3818359375, 9489.8232421875,
10401.216796875, 7707.87744140625, 5425.5654296875,
15802.0888671875, 14881.6220703125, 13502.23828125,
20126.2890625, 14589.1806640625, 6568.7900390625,
6181.41162109375, 12335.123046875, 12751.05078125,
11060.98046875, 10352.16015625, 10515.310546875,
16153.86328125, 17833.36328125, 15971.80859375
],
'descriptor': {shape: [2, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 4D and 4D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
56.46701431274414, 99.86045837402344, 71.054931640625,
32.454383850097656, 17.310747146606445, 2.586275100708008,
92.31499481201172, 96.9758529663086, 26.472131729125977,
77.67031860351562, 29.278789520263672, 82.12142181396484,
89.89308166503906, 82.49795532226562, 64.36865997314453,
23.75928497314453, 6.670266628265381, 81.55583190917969,
16.142963409423828, 57.45134735107422, 26.826417922973633,
85.02970123291016, 36.1988639831543, 89.60960388183594
],
'descriptor': {shape: [2, 1, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
70.38780212402344, 25.48917579650879, 28.254196166992188,
84.5148696899414, 58.873416900634766, 46.252838134765625,
24.897335052490234, 44.0944938659668, 51.86564636230469,
1.123237133026123, 4.187554836273193, 71.24649810791016,
16.034526824951172, 23.677297592163086, 61.27727508544922,
65.15946197509766, 58.39249801635742, 70.12741088867188,
9.11972713470459, 24.179977416992188, 84.4263687133789,
78.55551147460938, 38.48297119140625, 80.6541519165039,
57.152122497558594, 46.109710693359375, 28.41227912902832,
90.92566680908203, 94.66068267822266, 61.77287673950195,
60.324859619140625, 70.97433471679688, 10.631051063537598,
55.61628341674805, 35.052310943603516, 22.12839126586914,
38.19757843017578, 78.17564392089844, 62.57684326171875,
88.35256958007812
],
'descriptor': {shape: [2, 1, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
11005.6748046875, 10883.064453125, 9414.0009765625,
11929.9931640625, 8575.3720703125, 8043.556640625,
12745.41015625, 8884.0341796875, 4667.3173828125,
9023.7333984375, 10929.3818359375, 9489.8232421875,
10401.216796875, 7707.87744140625, 5425.5654296875,
15802.0888671875, 14881.6220703125, 13502.23828125,
20126.2890625, 14589.1806640625, 6568.7900390625,
6181.41162109375, 12335.123046875, 12751.05078125,
11060.98046875, 10352.16015625, 10515.310546875,
16153.86328125, 17833.36328125, 15971.80859375
],
'descriptor': {shape: [2, 1, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 3D and 3D (broadcast) tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
56.46701431274414, 99.86045837402344, 71.054931640625,
32.454383850097656, 17.310747146606445, 2.586275100708008,
92.31499481201172, 96.9758529663086, 26.472131729125977,
77.67031860351562, 29.278789520263672, 82.12142181396484,
89.89308166503906, 82.49795532226562, 64.36865997314453,
23.75928497314453, 6.670266628265381, 81.55583190917969,
16.142963409423828, 57.45134735107422, 26.826417922973633,
85.02970123291016, 36.1988639831543, 89.60960388183594
],
'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
27.829805374145508, 83.1454849243164, 34.41289520263672,
83.20379638671875
],
'descriptor': {shape: [1, 4, 1], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
15019.9462890625, 11942.376953125, 15035.0322265625,
13553.013671875, 12302.328125, 16517.9765625
],
'descriptor': {shape: [2, 3, 1], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 3D and 2D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
56.46701431274414, 99.86045837402344, 71.054931640625,
32.454383850097656, 17.310747146606445, 2.586275100708008,
92.31499481201172, 96.9758529663086, 26.472131729125977,
77.67031860351562, 29.278789520263672, 82.12142181396484,
89.89308166503906, 82.49795532226562, 64.36865997314453,
23.75928497314453, 6.670266628265381, 81.55583190917969,
16.142963409423828, 57.45134735107422, 26.826417922973633,
85.02970123291016, 36.1988639831543, 89.60960388183594
],
'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
27.829805374145508, 83.1454849243164, 34.41289520263672,
83.20379638671875
],
'descriptor': {shape: [4, 1], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
15019.9462890625, 11942.376953125, 15035.0322265625,
13553.013671875, 12302.328125, 16517.9765625
],
'descriptor': {shape: [2, 3, 1], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 4D and 4D (broadcast) tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
33.75957107543945, 97.24552917480469, 83.7085189819336,
64.53984069824219, 29.57938003540039, 17.19923973083496,
67.94749450683594, 97.45838165283203, 54.449283599853516,
29.552200317382812, 51.99970245361328, 36.03101348876953,
9.701058387756348, 27.04842185974121, 6.020919322967529,
22.940902709960938, 53.1243896484375, 15.292234420776367,
48.21302795410156, 87.40799713134766, 51.34442138671875,
21.1557559967041, 27.589487075805664, 58.412384033203125,
5.963276386260986, 84.74938201904297, 55.45738220214844,
50.858699798583984, 23.763574600219727, 62.330928802490234,
35.774959564208984, 17.340242385864258, 29.16901397705078,
23.191360473632812, 27.060928344726562, 1.2828527688980103,
8.720425605773926, 48.45281219482422, 99.0130386352539,
65.86412048339844, 92.69683074951172, 85.43540954589844,
37.49127960205078, 51.397132873535156, 53.19015121459961,
38.33119201660156, 75.20586395263672, 3.8537938594818115
],
'descriptor': {shape: [2, 2, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
88.1700439453125, 78.4012680053711, 14.819003105163574,
3.6923038959503174, 45.906429290771484, 43.083919525146484,
47.199466705322266, 60.92521667480469, 8.162760734558105,
20.333263397216797, 20.438398361206055, 27.0194091796875,
15.601424217224121, 87.46969604492188, 65.79554748535156,
69.31697082519531, 31.984439849853516, 12.291812896728516,
13.304834365844727, 85.26705169677734
],
'descriptor': {shape: [1, 1, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
13350.8759765625, 11562.755859375, 8524.271484375,
9099.0927734375, 14537.8701171875, 11493.283203125,
8083.90869140625, 3744.22216796875, 7489.62353515625,
14488.2314453125, 9634.3720703125, 8221.173828125,
3861.51416015625, 5470.0556640625, 9594.072265625,
3733.946533203125, 2933.679931640625, 2167.611083984375,
1088.48193359375, 3347.576416015625, 12387.083984375,
8985.1884765625, 3545.52783203125, 5701.10595703125,
13374.9169921875, 10051.3671875, 7637.7470703125,
3198.221435546875, 3552.6796875, 9583.1220703125,
8835.94921875, 7592.7666015625, 6742.10400390625,
6241.31396484375, 9982.404296875, 6713.85205078125,
6326.3173828125, 4920.9609375, 3956.46875,
6190.67626953125, 4213.013671875, 4153.708984375,
2283.152099609375, 2681.085693359375, 3700.47509765625,
9445.5869140625, 7752.5400390625, 5435.56005859375,
9964.6591796875, 13516.18359375, 16182.931640625,
13956.9560546875, 7795.52685546875, 5002.8349609375,
12841.802734375, 8145.45654296875, 8134.66650390625,
4344.25, 7138.79052734375, 8497.98046875
],
'descriptor': {shape: [2, 2, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 4D and 3D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
33.75957107543945, 97.24552917480469, 83.7085189819336,
64.53984069824219, 29.57938003540039, 17.19923973083496,
67.94749450683594, 97.45838165283203, 54.449283599853516,
29.552200317382812, 51.99970245361328, 36.03101348876953,
9.701058387756348, 27.04842185974121, 6.020919322967529,
22.940902709960938, 53.1243896484375, 15.292234420776367,
48.21302795410156, 87.40799713134766, 51.34442138671875,
21.1557559967041, 27.589487075805664, 58.412384033203125,
5.963276386260986, 84.74938201904297, 55.45738220214844,
50.858699798583984, 23.763574600219727, 62.330928802490234,
35.774959564208984, 17.340242385864258, 29.16901397705078,
23.191360473632812, 27.060928344726562, 1.2828527688980103,
8.720425605773926, 48.45281219482422, 99.0130386352539,
65.86412048339844, 92.69683074951172, 85.43540954589844,
37.49127960205078, 51.397132873535156, 53.19015121459961,
38.33119201660156, 75.20586395263672, 3.8537938594818115
],
'descriptor': {shape: [2, 2, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
70.38780212402344, 25.48917579650879, 28.254196166992188,
84.5148696899414, 58.873416900634766, 46.252838134765625,
24.897335052490234, 44.0944938659668, 51.86564636230469,
1.123237133026123, 4.187554836273193, 71.24649810791016,
16.034526824951172, 23.677297592163086, 61.27727508544922,
65.15946197509766, 58.39249801635742, 70.12741088867188,
9.11972713470459, 24.179977416992188, 84.4263687133789,
78.55551147460938, 38.48297119140625, 80.6541519165039,
57.152122497558594, 46.109710693359375, 28.41227912902832,
90.92566680908203, 94.66068267822266, 61.77287673950195,
60.324859619140625, 70.97433471679688, 10.631051063537598,
55.61628341674805, 35.052310943603516, 22.12839126586914,
38.19757843017578, 78.17564392089844, 62.57684326171875,
88.35256958007812
],
'descriptor': {shape: [2, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
11430.05859375, 13014.2392578125, 11110.080078125,
10467.46484375, 8786.7724609375, 9512.4111328125,
11714.0283203125, 9518.1435546875, 5889.55419921875,
8280.9365234375, 7764.95166015625, 7932.3759765625,
6202.0625, 7694.32373046875, 7296.4384765625,
2937.076416015625, 2834.196533203125, 4690.14990234375,
5113.283203125, 4463.22998046875, 10032.8623046875,
11368.3623046875, 10780.572265625, 13883.421875,
13393.5166015625, 8267.212890625, 8823.828125,
8759.2177734375, 11333.4462890625, 10369.25390625,
7885.7978515625, 9182.943359375, 8361.2900390625,
6676.46533203125, 5074.3115234375, 5835.33837890625,
5718.96875, 5209.5322265625, 6246.40185546875,
4080.533935546875, 3322.71826171875, 3323.802490234375,
2370.630615234375, 4320.47900390625, 3432.568115234375,
10400.7939453125, 11604.9267578125, 10942.7744140625,
14918.220703125, 12781.3603515625, 15164.451171875,
14333.4267578125, 15752.0966796875, 20865.154296875,
16430.63671875, 10880.1533203125, 10752.34765625,
6632.99462890625, 12342.2919921875, 8384.3896484375
],
'descriptor': {shape: [2, 2, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name':
'matmul float32 5D and 5D tensors, broadcast the two leftmost dimensions of inputB',
'graph': {
'inputs': {
'inputA': {
'data': [
33.75957107543945, 97.24552917480469, 83.7085189819336,
64.53984069824219, 29.57938003540039, 17.19923973083496,
67.94749450683594, 97.45838165283203, 54.449283599853516,
29.552200317382812, 51.99970245361328, 36.03101348876953,
9.701058387756348, 27.04842185974121, 6.020919322967529,
22.940902709960938, 53.1243896484375, 15.292234420776367,
48.21302795410156, 87.40799713134766, 51.34442138671875,
21.1557559967041, 27.589487075805664, 58.412384033203125,
5.963276386260986, 84.74938201904297, 55.45738220214844,
50.858699798583984, 23.763574600219727, 62.330928802490234,
35.774959564208984, 17.340242385864258, 29.16901397705078,
23.191360473632812, 27.060928344726562, 1.2828527688980103,
8.720425605773926, 48.45281219482422, 99.0130386352539,
65.86412048339844, 92.69683074951172, 85.43540954589844,
37.49127960205078, 51.397132873535156, 53.19015121459961,
38.33119201660156, 75.20586395263672, 3.8537938594818115
],
'descriptor': {shape: [2, 2, 1, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
88.1700439453125, 78.4012680053711, 14.819003105163574,
3.6923038959503174, 45.906429290771484, 43.083919525146484,
47.199466705322266, 60.92521667480469, 8.162760734558105,
20.333263397216797, 20.438398361206055, 27.0194091796875,
15.601424217224121, 87.46969604492188, 65.79554748535156,
69.31697082519531, 31.984439849853516, 12.291812896728516,
13.304834365844727, 85.26705169677734
],
'descriptor': {shape: [1, 1, 1, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
13350.8759765625, 11562.755859375, 8524.271484375,
9099.0927734375, 14537.8701171875, 11493.283203125,
8083.90869140625, 3744.22216796875, 7489.62353515625,
14488.2314453125, 9634.3720703125, 8221.173828125,
3861.51416015625, 5470.0556640625, 9594.072265625,
3733.946533203125, 2933.679931640625, 2167.611083984375,
1088.48193359375, 3347.576416015625, 12387.083984375,
8985.1884765625, 3545.52783203125, 5701.10595703125,
13374.9169921875, 10051.3671875, 7637.7470703125,
3198.221435546875, 3552.6796875, 9583.1220703125,
8835.94921875, 7592.7666015625, 6742.10400390625,
6241.31396484375, 9982.404296875, 6713.85205078125,
6326.3173828125, 4920.9609375, 3956.46875,
6190.67626953125, 4213.013671875, 4153.708984375,
2283.152099609375, 2681.085693359375, 3700.47509765625,
9445.5869140625, 7752.5400390625, 5435.56005859375,
9964.6591796875, 13516.18359375, 16182.931640625,
13956.9560546875, 7795.52685546875, 5002.8349609375,
12841.802734375, 8145.45654296875, 8134.66650390625,
4344.25, 7138.79052734375, 8497.98046875
],
'descriptor': {shape: [2, 2, 1, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name':
'matmul float32 5D and 5D tensors, broadcast the leftmost dimensions of inputB',
'graph': {
'inputs': {
'inputA': {
'data': [
33.75957107543945, 97.24552917480469, 83.7085189819336,
64.53984069824219, 29.57938003540039, 17.19923973083496,
67.94749450683594, 97.45838165283203, 54.449283599853516,
29.552200317382812, 51.99970245361328, 36.03101348876953,
9.701058387756348, 27.04842185974121, 6.020919322967529,
22.940902709960938, 53.1243896484375, 15.292234420776367,
48.21302795410156, 87.40799713134766, 51.34442138671875,
21.1557559967041, 27.589487075805664, 58.412384033203125,
5.963276386260986, 84.74938201904297, 55.45738220214844,
50.858699798583984, 23.763574600219727, 62.330928802490234,
35.774959564208984, 17.340242385864258, 29.16901397705078,
23.191360473632812, 27.060928344726562, 1.2828527688980103,
8.720425605773926, 48.45281219482422, 99.0130386352539,
65.86412048339844, 92.69683074951172, 85.43540954589844,
37.49127960205078, 51.397132873535156, 53.19015121459961,
38.33119201660156, 75.20586395263672, 3.8537938594818115
],
'descriptor': {shape: [2, 2, 1, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
88.1700439453125, 78.4012680053711, 14.819003105163574,
3.6923038959503174, 45.906429290771484, 43.083919525146484,
47.199466705322266, 60.92521667480469, 8.162760734558105,
20.333263397216797, 20.438398361206055, 27.0194091796875,
15.601424217224121, 87.46969604492188, 65.79554748535156,
69.31697082519531, 31.984439849853516, 12.291812896728516,
13.304834365844727, 85.26705169677734, 88.1700439453125,
78.4012680053711, 14.819003105163574, 3.6923038959503174,
45.906429290771484, 43.083919525146484, 47.199466705322266,
60.92521667480469, 8.162760734558105, 20.333263397216797,
20.438398361206055, 27.0194091796875, 15.601424217224121,
87.46969604492188, 65.79554748535156, 69.31697082519531,
31.984439849853516, 12.291812896728516, 13.304834365844727,
85.26705169677734
],
'descriptor': {shape: [1, 2, 1, 4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
13350.8759765625, 11562.755859375, 8524.271484375,
9099.0927734375, 14537.8701171875, 11493.283203125,
8083.90869140625, 3744.22216796875, 7489.62353515625,
14488.2314453125, 9634.3720703125, 8221.173828125,
3861.51416015625, 5470.0556640625, 9594.072265625,
3733.946533203125, 2933.679931640625, 2167.611083984375,
1088.48193359375, 3347.576416015625, 12387.083984375,
8985.1884765625, 3545.52783203125, 5701.10595703125,
13374.9169921875, 10051.3671875, 7637.7470703125,
3198.221435546875, 3552.6796875, 9583.1220703125,
8835.94921875, 7592.7666015625, 6742.10400390625,
6241.31396484375, 9982.404296875, 6713.85205078125,
6326.3173828125, 4920.9609375, 3956.46875,
6190.67626953125, 4213.013671875, 4153.708984375,
2283.152099609375, 2681.085693359375, 3700.47509765625,
9445.5869140625, 7752.5400390625, 5435.56005859375,
9964.6591796875, 13516.18359375, 16182.931640625,
13956.9560546875, 7795.52685546875, 5002.8349609375,
12841.802734375, 8145.45654296875, 8134.66650390625,
4344.25, 7138.79052734375, 8497.98046875
],
'descriptor': {shape: [2, 2, 1, 3, 5], dataType: 'float32'}
}
}
}
},
{
'name': 'matmul float32 5D and 2D tensors',
'graph': {
'inputs': {
'inputA': {
'data': [
33.75957107543945, 97.24552917480469, 83.7085189819336,
64.53984069824219, 29.57938003540039, 17.19923973083496,
67.94749450683594, 97.45838165283203, 54.449283599853516,
29.552200317382812, 51.99970245361328, 36.03101348876953,
9.701058387756348, 27.04842185974121, 6.020919322967529,
22.940902709960938, 53.1243896484375, 15.292234420776367,
48.21302795410156, 87.40799713134766, 51.34442138671875,
21.1557559967041, 27.589487075805664, 58.412384033203125,
5.963276386260986, 84.74938201904297, 55.45738220214844,
50.858699798583984, 23.763574600219727, 62.330928802490234,
35.774959564208984, 17.340242385864258, 29.16901397705078,
23.191360473632812, 27.060928344726562, 1.2828527688980103,
8.720425605773926, 48.45281219482422, 99.0130386352539,
65.86412048339844, 92.69683074951172, 85.43540954589844,
37.49127960205078, 51.397132873535156, 53.19015121459961,
38.33119201660156, 75.20586395263672, 3.8537938594818115
],
'descriptor': {shape: [2, 2, 1, 3, 4], dataType: 'float32'}
},
'inputB': {
'data': [
88.1700439453125, 78.4012680053711, 14.819003105163574,
3.6923038959503174, 45.906429290771484, 43.083919525146484,
47.199466705322266, 60.92521667480469, 8.162760734558105,
20.333263397216797, 20.438398361206055, 27.0194091796875,
15.601424217224121, 87.46969604492188, 65.79554748535156,
69.31697082519531, 31.984439849853516, 12.291812896728516,
13.304834365844727, 85.26705169677734
],
'descriptor': {shape: [4, 5], dataType: 'float32'}
}
},
'operators': [{
'name': 'matmul',
'arguments': [{'a': 'inputA'}, {'b': 'inputB'}],
'outputs': 'output'
}],
'expectedOutputs': {
'output': {
'data': [
13350.8759765625, 11562.755859375, 8524.271484375,
9099.0927734375, 14537.8701171875, 11493.283203125,
8083.90869140625, 3744.22216796875, 7489.62353515625,
14488.2314453125, 9634.3720703125, 8221.173828125,
3861.51416015625, 5470.0556640625, 9594.072265625,
3733.946533203125, 2933.679931640625, 2167.611083984375,
1088.48193359375, 3347.576416015625, 12387.083984375,
8985.1884765625, 3545.52783203125, 5701.10595703125,
13374.9169921875, 10051.3671875, 7637.7470703125,
3198.221435546875, 3552.6796875, 9583.1220703125,
8835.94921875, 7592.7666015625, 6742.10400390625,
6241.31396484375, 9982.404296875, 6713.85205078125,
6326.3173828125, 4920.9609375, 3956.46875,
6190.67626953125, 4213.013671875, 4153.708984375,
2283.152099609375, 2681.085693359375, 3700.47509765625,
9445.5869140625, 7752.5400390625, 5435.56005859375,
9964.6591796875, 13516.18359375, 16182.931640625,
13956.9560546875, 7795.52685546875, 5002.8349609375,
12841.802734375, 8145.45654296875, 8134.66650390625,
4344.25, 7138.79052734375, 8497.98046875
],
'descriptor': {shape: [2, 2, 1, 3, 5], dataType: 'float32'}
}
}
}
}
];
if (navigator.ml) {
matmulTests.forEach((test) => {
webnn_conformance_test(
buildAndExecuteGraph, getMatmulPrecisionTolerance, test);
});
} else {
test(() => assert_implements(navigator.ml, 'missing navigator.ml'));
}