Skip to content
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
10 changes: 10 additions & 0 deletions webnn/relu.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// META: title=test WebNN API relu operation
// META: global=window,dedicatedworker
// META: script=./resources/utils.js
// META: timeout=long

'use strict';

// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-relu

testWebNNOperation('relu', '/webnn/resources/test_data/relu.json', buildOperationWithSingleInput);
334 changes: 334 additions & 0 deletions webnn/resources/test_data/relu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,334 @@
{
"tests": [ // relu input tensor of 1D to 5D with same data values
{
"name": "relu float32 1D tensor",
"inputs": {
"x": {
"shape": [24],
"data": [
79.04725231657116,
2.2503608756501166,
80.73939090529203,
63.90392076789547,
77.67340745512104,
-71.09157819044825,
-82.74703468427575,
-26.814426600801028,
-99.16788836397058,
-35.71083406288831,
18.36165830990626,
-37.36091648205435,
-52.8386119809162,
-10.408374773008958,
60.60291560236189,
-13.644198913810342,
-76.54250291031946,
-8.132338049258351,
51.51447452437017,
-51.63370281825297,
-64.567999424324,
-5.093302411117136,
15.354103550744384,
90.03858807393516
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
79.04724884033203,
2.2503609657287598,
80.73938751220703,
63.9039192199707,
77.67340850830078,
0,
0,
0,
0,
0,
18.361658096313477,
0,
0,
0,
60.6029167175293,
0,
0,
0,
51.51447296142578,
0,
0,
0,
15.354103088378906,
90.03858947753906
],
"type": "float32"
}
},
{
"name": "relu float32 2D tensor",
"inputs": {
"x": {
"shape": [4, 6],
"data": [
79.04725231657116,
2.2503608756501166,
80.73939090529203,
63.90392076789547,
77.67340745512104,
-71.09157819044825,
-82.74703468427575,
-26.814426600801028,
-99.16788836397058,
-35.71083406288831,
18.36165830990626,
-37.36091648205435,
-52.8386119809162,
-10.408374773008958,
60.60291560236189,
-13.644198913810342,
-76.54250291031946,
-8.132338049258351,
51.51447452437017,
-51.63370281825297,
-64.567999424324,
-5.093302411117136,
15.354103550744384,
90.03858807393516
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [4, 6],
"data": [
79.04724884033203,
2.2503609657287598,
80.73938751220703,
63.9039192199707,
77.67340850830078,
0,
0,
0,
0,
0,
18.361658096313477,
0,
0,
0,
60.6029167175293,
0,
0,
0,
51.51447296142578,
0,
0,
0,
15.354103088378906,
90.03858947753906
],
"type": "float32"
}
},
{
"name": "relu float32 3D tensor",
"inputs": {
"x": {
"shape": [2, 3, 4],
"data": [
79.04725231657116,
2.2503608756501166,
80.73939090529203,
63.90392076789547,
77.67340745512104,
-71.09157819044825,
-82.74703468427575,
-26.814426600801028,
-99.16788836397058,
-35.71083406288831,
18.36165830990626,
-37.36091648205435,
-52.8386119809162,
-10.408374773008958,
60.60291560236189,
-13.644198913810342,
-76.54250291031946,
-8.132338049258351,
51.51447452437017,
-51.63370281825297,
-64.567999424324,
-5.093302411117136,
15.354103550744384,
90.03858807393516
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 3, 4],
"data": [
79.04724884033203,
2.2503609657287598,
80.73938751220703,
63.9039192199707,
77.67340850830078,
0,
0,
0,
0,
0,
18.361658096313477,
0,
0,
0,
60.6029167175293,
0,
0,
0,
51.51447296142578,
0,
0,
0,
15.354103088378906,
90.03858947753906
],
"type": "float32"
}
},
{
"name": "relu float32 4D tensor",
"inputs": {
"x": {
"shape": [2, 2, 2, 3],
"data": [
79.04725231657116,
2.2503608756501166,
80.73939090529203,
63.90392076789547,
77.67340745512104,
-71.09157819044825,
-82.74703468427575,
-26.814426600801028,
-99.16788836397058,
-35.71083406288831,
18.36165830990626,
-37.36091648205435,
-52.8386119809162,
-10.408374773008958,
60.60291560236189,
-13.644198913810342,
-76.54250291031946,
-8.132338049258351,
51.51447452437017,
-51.63370281825297,
-64.567999424324,
-5.093302411117136,
15.354103550744384,
90.03858807393516
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 2, 2, 3],
"data": [
79.04724884033203,
2.2503609657287598,
80.73938751220703,
63.9039192199707,
77.67340850830078,
0,
0,
0,
0,
0,
18.361658096313477,
0,
0,
0,
60.6029167175293,
0,
0,
0,
51.51447296142578,
0,
0,
0,
15.354103088378906,
90.03858947753906
],
"type": "float32"
}
},
{
"name": "relu float32 5D tensor",
"inputs": {
"x": {
"shape": [2, 1, 4, 1, 3],
"data": [
79.04725231657116,
2.2503608756501166,
80.73939090529203,
63.90392076789547,
77.67340745512104,
-71.09157819044825,
-82.74703468427575,
-26.814426600801028,
-99.16788836397058,
-35.71083406288831,
18.36165830990626,
-37.36091648205435,
-52.8386119809162,
-10.408374773008958,
60.60291560236189,
-13.644198913810342,
-76.54250291031946,
-8.132338049258351,
51.51447452437017,
-51.63370281825297,
-64.567999424324,
-5.093302411117136,
15.354103550744384,
90.03858807393516
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 1, 4, 1, 3],
"data": [
79.04724884033203,
2.2503609657287598,
80.73938751220703,
63.9039192199707,
77.67340850830078,
0,
0,
0,
0,
0,
18.361658096313477,
0,
0,
0,
60.6029167175293,
0,
0,
0,
51.51447296142578,
0,
0,
0,
15.354103088378906,
90.03858947753906
],
"type": "float32"
}
}
]
}
1 change: 1 addition & 0 deletions webnn/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const getExpectedData = (resources, outputName) => {
const PrecisionMetrics = {
clamp: {ULP: {float32: 0, float16: 0}},
concat: {ULP: {float32: 0, float16: 0}},
relu: {ULP: {float32: 0, float16: 0}},
reshape: {ULP: {float32: 0, float16: 0}},
};

Expand Down