From 3ab2d1f0f502b2035afe112b7ed6131621597af5 Mon Sep 17 00:00:00 2001
From: Reilly Grant
+ Device preference: + +
++ Power preference: + +
++ Number of threads: + +
@@ -18,6 +38,9 @@ const aInput = document.getElementById('a'); const bInput = document.getElementById('b'); const cOutput = document.getElementById('c'); + const deviceOption = document.getElementById('device'); + const powerOption = document.getElementById('power'); + const threadsOption = document.getElementById('threads'); const buildButton = document.getElementById('build'); const computeButton = document.getElementById('compute'); const outputSpan = document.getElementById('output'); @@ -29,7 +52,14 @@ try { computeButton.disabled = true; - context = await navigator.ml.createContext(); + const options = { + devicePreference: deviceOption.value, + powerPreference: powerOption.value, + numThreads: threadsOption.value, + }; + console.log(options); + context = await navigator.ml.createContext(options); + const builder = new MLGraphBuilder(context); const operandType = {dataType: 'float32', dimensions: [1]}; const a = builder.input('a', operandType);