summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webnn/idlharness.https.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webnn/idlharness.https.any.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/web-platform/tests/webnn/idlharness.https.any.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webnn/idlharness.https.any.js b/testing/web-platform/tests/webnn/idlharness.https.any.js
new file mode 100644
index 0000000000..6122134268
--- /dev/null
+++ b/testing/web-platform/tests/webnn/idlharness.https.any.js
@@ -0,0 +1,58 @@
+// META: global=window,dedicatedworker
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+// META: script=./resources/utils.js
+// META: timeout=long
+
+// https://webmachinelearning.github.io/webnn/
+
+'use strict';
+
+idl_test(
+ ['webnn'],
+ ['html', 'webidl', 'webgpu'],
+ async (idl_array) => {
+ if (self.GLOBAL.isWindow()) {
+ idl_array.add_objects({ Navigator: ['navigator'] });
+ } else if (self.GLOBAL.isWorker()) {
+ idl_array.add_objects({ WorkerNavigator: ['navigator'] });
+ }
+
+ idl_array.add_objects({
+ NavigatorML: ['navigator'],
+ ML: ['navigator.ml'],
+ MLContext: ['context'],
+ MLOperand: ['input', 'filter', 'output'],
+ MLOperator: ['relu'],
+ MLGraphBuilder: ['builder'],
+ MLGraph: ['graph']
+ });
+
+ for (const executionType of ExecutionArray) {
+ const isSync = executionType === 'sync';
+ if (self.GLOBAL.isWindow() && isSync) {
+ continue;
+ }
+
+ for (const deviceType of DeviceTypeArray) {
+ if (isSync) {
+ self.context = navigator.ml.createContextSync({deviceType});
+ } else {
+ self.context = await navigator.ml.createContext({deviceType});
+ }
+
+ self.builder = new MLGraphBuilder(self.context);
+ self.input = builder.input('input', {type: 'float32', dimensions: [1, 1, 5, 5]});
+ self.filter = builder.constant({type: 'float32', dimensions: [1, 1, 3, 3]}, new Float32Array(9).fill(1));
+ self.relu = builder.relu();
+ self.output = builder.conv2d(input, filter, {activation: relu, inputLayout: "nchw"});
+
+ if (isSync) {
+ self.graph = builder.buildSync({output});
+ } else {
+ self.graph = await builder.build({output});
+ }
+ }
+ }
+ }
+);