WebNN: Define XNNPACK Node for matmul
This CL implements DefineXnnNodeForMatmul() method that defines XNNPACK
matmul Node by xnn_define_batch_matrix_multiply().
For unit tests, this CL implements MatmulTest of MLGraphTest that
checks the compute results of matmul operators.
Bug: 1273291
Change-Id: Ife8e1023804d4b9970bfff067fbeedbf12ba313e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5232604
Commit-Queue: Lisha Guo <lisha.guo@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1255409}
diff --git a/webnn/resources/test_data/matmul.json b/webnn/resources/test_data/matmul.json
index 2477b78..f3a03e4 100644
--- a/webnn/resources/test_data/matmul.json
+++ b/webnn/resources/test_data/matmul.json
@@ -516,6 +516,124 @@
}
},
{
+ "name": "matmul float32 4D and 4D tensors",
+ "inputs": {
+ "a": {
+ "shape": [2, 1, 3, 4],
+ "data": [
+ 56.46701250066562,
+ 99.86045478237251,
+ 71.05493372292567,
+ 32.45438455331333,
+ 17.310747999630017,
+ 2.586275053048559,
+ 92.31499166302054,
+ 96.9758519231732,
+ 26.4721315276526,
+ 77.67031776320978,
+ 29.278788710989147,
+ 82.12142428847062,
+ 89.89308471484885,
+ 82.49795321217854,
+ 64.36866008901963,
+ 23.75928513568486,
+ 6.67026681065197,
+ 81.55583129445503,
+ 16.142963270263433,
+ 57.45134849716054,
+ 26.82641739603182,
+ 85.0296980735713,
+ 36.198863464757956,
+ 89.60960360138286
+ ],
+ "type": "float32"
+ },
+ "b": {
+ "shape": [2, 1, 4, 5],
+ "data": [
+ 70.38780515954635,
+ 25.489176068987597,
+ 28.25419591483602,
+ 84.51486608529449,
+ 58.87341530615436,
+ 46.252837428713555,
+ 24.897335441310766,
+ 44.09449366886899,
+ 51.865646783698985,
+ 1.123237180407144,
+ 4.187554708673558,
+ 71.24650172124491,
+ 16.0345266486708,
+ 23.677297120787454,
+ 61.277276711169094,
+ 65.15946418752658,
+ 58.392497125216906,
+ 70.12740970610143,
+ 9.119727538574839,
+ 24.17997835305117,
+ 84.42636665997716,
+ 78.55551451746716,
+ 38.482969428827076,
+ 80.65414903244603,
+ 57.15212267967695,
+ 46.10971199065528,
+ 28.41227860070996,
+ 90.9256677352717,
+ 94.66067935241847,
+ 61.772877196686295,
+ 60.324859158187635,
+ 70.97433442190315,
+ 10.631051143172332,
+ 55.616284948780525,
+ 35.0523090419651,
+ 22.128390497020668,
+ 38.19757703840079,
+ 78.17564687251797,
+ 62.57684276680773,
+ 88.35256743439288
+ ],
+ "type": "float32"
+ }
+ },
+ "expected": {
+ "name": "output",
+ "shape": [2, 1, 3, 5],
+ "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
+ ],
+ "type": "float32"
+ }
+ },
+ {
"name": "matmul float32 3D and 3D (broadcast) tensors",
"inputs": {
"a": {