Skip to content

Commit

Permalink
[js/webgpu] fix Conv2DMatMul shader's out-of-bound read
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed Dec 11, 2024
1 parent 2f2c73b commit 943e2b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/web/lib/wasm/jsep/webgpu/ops/3rd-party/conv2d_mm_webgpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,15 @@ const conv2dCommonSnippet = (
}
return ${typeSnippet(innerElementSizeX, dataType)}(0.0);`;

const sampleW = `${getWSnippet(innerElementSizeW)}`;
const sampleW =
fitInner && fitBOuter
? getWSnippet(innerElementSizeW)
: `
let col = colIn * ${innerElementSizeW};
if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) {
${getWSnippet(innerElementSizeW)}
}
return ${typeSnippet(innerElementSizeW, dataType)}(0.0);`;

const resType = typeSnippet(innerElementSize, dataType);
const aType = isChannelsLast ? typeSnippet(innerElementSizeX, dataType) : typeSnippet(innerElementSizeW, dataType);
Expand Down

0 comments on commit 943e2b5

Please sign in to comment.