Skip to content

Commit

Permalink
Recreate conv2d input when data type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
reillyeon committed Jul 26, 2024
1 parent 96b97db commit 4174485
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webnn-conv2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

let context;
let graph;
let inputData;
let inputs = {input: null};
let outputs = {output: null};
let inputBuffer;
Expand Down Expand Up @@ -273,7 +274,7 @@
const inputCanvas = document.getElementById('input');
const inputCtx = inputCanvas.getContext('2d');
inputCtx.drawImage(image, 0, 0);
const inputData = inputCtx.getImageData(0, 0, image.width, image.height);
inputData = inputCtx.getImageData(0, 0, image.width, image.height);
inputs.input = imageDataToTensor(inputData);

if (!('ml' in navigator)) {
Expand Down Expand Up @@ -307,7 +308,10 @@
deviceTypeElement.onchange = contextOptionsChanged

const dataTypeOption = document.getElementById('dataType');
dataTypeOption.onchange = graphOptionsChanged;
dataTypeOption.onchange = () => {
inputs.input = imageDataToTensor(inputData);
graphOptionsChanged();
};

const filterTypeElement = document.getElementById('filterType');
filterTypeElement.onchange = () => {
Expand Down

0 comments on commit 4174485

Please sign in to comment.