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: Allow 0-D (scalar) reductions #46209

Merged
merged 1 commit into from
May 15, 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
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_l1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceL1 float32 0D constant tensor default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
"input": {
"shape": [],
"data": [
5.50882625579834
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 5.50882625579834,
"type": "float32"
}
},
{
"name": "reduceL1 float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
5.50882625579834
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 5.50882625579834,
"type": "float32"
}
},
{
"name": "reduceL1 float32 1D constant tensor all positive default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_l2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceL2 float32 0D constant tensor default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
"input": {
"shape": [],
"data": [
4.860228061676025
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 4.860228061676025,
"type": "float32"
}
},
{
"name": "reduceL2 float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
4.860228061676025
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 4.860228061676025,
"type": "float32"
}
},
{
"name": "reduceL2 float32 1D constant tensor all positive default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_log_sum.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceLogSum float32 0D constant tensor default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
"input": {
"shape": [],
"data": [
64.54827117919922
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 4.167413234710693,
"type": "float32"
}
},
{
"name": "reduceLogSum float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
64.54827117919922
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 4.167413234710693,
"type": "float32"
}
},
{
"name": "reduceLogSum float32 1D constant tensor all non-negative default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_log_sum_exp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceLogSumExp float32 0D constant tensor default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
"input": {
"shape": [],
"data": [
0.7974132895469666
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 0.7974132895469666,
"type": "float32"
}
},
{
"name": "reduceLogSumExp float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
0.7974132895469666
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 0.7974132895469666,
"type": "float32"
}
},
{
"name": "reduceLogSumExp float32 1D constant tensor all positive default options", // default options: {axes: null, keepDimensions: false}
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_max.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceMax float32 0D constant tensor default options",
"inputs": {
"input": {
"shape": [],
"data": [
32.16658401489258
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 32.16658401489258,
"type": "float32"
}
},
{
"name": "reduceMax float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
32.16658401489258
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 32.16658401489258,
"type": "float32"
}
},
{
"name": "reduceMax float32 1D constant tensor default options",
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_mean.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceMean float32 0D constant tensor default options",
"inputs": {
"input": {
"shape": [],
"data": [
95.84498596191406
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": 95.84498596191406,
"type": "float32"
}
},
{
"name": "reduceMean float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
95.84498596191406
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": 95.84498596191406,
"type": "float32"
}
},
{
"name": "reduceMean float32 1D constant tensor all positive default options",
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_min.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceMin float32 0D constant tensor default options",
"inputs": {
"input": {
"shape": [],
"data": [
-58.76195526123047
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": -58.76195526123047,
"type": "float32"
}
},
{
"name": "reduceMin float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
-58.76195526123047
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": -58.76195526123047,
"type": "float32"
}
},
{
"name": "reduceMin float32 1D constant tensor default options",
"inputs": {
Expand Down
39 changes: 39 additions & 0 deletions webnn/resources/test_data/reduce_product.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
{
"tests": [
{
"name": "reduceProduct float32 0D constant tensor default options",
"inputs": {
"input": {
"shape": [],
"data": [
-68.75911712646484
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"data": -68.75911712646484,
"type": "float32"
}
},
{
"name": "reduceProduct float32 0D constant tensor empty axes",
"inputs": {
"input": {
"shape": [],
"data": [
-68.75911712646484
],
"type": "float32",
"constant": true
}
},
"options": {
"axes": []
},
"expected": {
"name": "output",
"data": -68.75911712646484,
"type": "float32"
}
},
{
"name": "reduceProduct float32 1D constant tensor default options",
"inputs": {
Expand Down
Loading