forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,842 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// META: title=test WebNN API clamp operation | ||
// META: global=window,dedicatedworker | ||
// META: script=./resources/utils.js | ||
// META: timeout=long | ||
|
||
'use strict'; | ||
|
||
// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-clamp | ||
|
||
const computeClamp = (builder, resources) => { | ||
// MLOperand clamp(MLOperand x, optional MLClampOptions options = {}); | ||
// use 'x' for input operand name | ||
const [inputOperand] = createInputOperands(builder, resources, ['x']); | ||
return builder.clamp(inputOperand, resources.options); | ||
}; | ||
|
||
testWebNNOperation('clamp', '/webnn/resources/test_data/clamp.json', computeClamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// META: title=test WebNN API gemm operation | ||
// META: global=window,dedicatedworker | ||
// META: script=./resources/utils.js | ||
// META: timeout=long | ||
|
||
'use strict'; | ||
|
||
// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-gemm | ||
|
||
const computeGemm = (builder, resources) => { | ||
// MLOperand gemm(MLOperand a, MLOperand b, optional MLGemmOptions options = {}); | ||
// use 'a' and 'b' for input operands name | ||
const [inputOperandA, inputOperandB] = createInputOperands(builder, resources, ['a', 'b']); | ||
const operandType = resources.type; | ||
const TestTypedArray = TypedArrayDict[operandType]; | ||
const options = resources.options; | ||
const gemmOptions = {}; | ||
if (options !== undefined) { | ||
if (options.c !== undefined) { | ||
if (typeof options.c === 'number') { | ||
// scalar | ||
gemmOptions.c = new TestTypedArray([options.c])[0]; | ||
} else { | ||
gemmOptions.c = builder.constant({type: operandType, dimensions: options.c.shape}, new TestTypedArray(options.c.data)); | ||
} | ||
} | ||
if (options.alpha !== undefined) { | ||
// scalar | ||
gemmOptions.alpha = new TestTypedArray([options.alpha])[0]; | ||
} | ||
if (options.beta !== undefined) { | ||
// scalar | ||
gemmOptions.beta = new TestTypedArray([options.beta])[0]; | ||
} | ||
if (options.aTranspose !== undefined) { | ||
gemmOptions.aTranspose = options.aTranspose; | ||
} | ||
if (options.bTranspose !== undefined) { | ||
gemmOptions.bTranspose = options.bTranspose; | ||
} | ||
} | ||
return builder.gemm(inputOperandA, inputOperandB, gemmOptions); | ||
}; | ||
|
||
testWebNNOperation('gemm', '/webnn/resources/test_data/gemm.json', computeGemm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// META: title=test WebNN API matmul operation | ||
// META: global=window,dedicatedworker | ||
// META: script=./resources/utils.js | ||
// META: timeout=long | ||
|
||
'use strict'; | ||
|
||
// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-matmul | ||
|
||
const computeMatmul = (builder, resources) => { | ||
// MLOperand matmul(MLOperand a, MLOperand b); | ||
// use 'a' and 'b' for input operands name | ||
const [inputOperandA, inputOperandB] = createInputOperands(builder, resources, ['a', 'b']); | ||
return builder.matmul(inputOperandA, inputOperandB); | ||
}; | ||
|
||
testWebNNOperation('matmul', '/webnn/resources/test_data/matmul.json', computeMatmul); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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 | ||
|
||
const computeRelu = (builder, resources) => { | ||
// MLOperand relu(MLOperand x); | ||
// use 'x' for input operand name | ||
const [inputOperand] = createInputOperands(builder, resources, ['x']); | ||
return builder.relu(inputOperand); | ||
}; | ||
|
||
testWebNNOperation('relu', '/webnn/resources/test_data/relu.json', computeRelu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// META: title=test WebNN API reshape operation | ||
// META: global=window,dedicatedworker | ||
// META: script=./resources/utils.js | ||
// META: timeout=long | ||
|
||
'use strict'; | ||
|
||
// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-reshape | ||
|
||
const computeReshape = (builder, resources) => { | ||
// MLOperand reshape(MLOperand input, sequence<long> newShape); | ||
// use 'input' for input operand name | ||
const [inputOperand] = createInputOperands(builder, resources, ['input']); | ||
return builder.reshape(inputOperand, resources.newShape); | ||
}; | ||
|
||
testWebNNOperation('reshape', '/webnn/resources/test_data/reshape.json', computeReshape); | ||
|
Oops, something went wrong.