From 0073ab7c62c2d2d2b85c7f839028f906cbe81e6a Mon Sep 17 00:00:00 2001 From: Yunfei Hao Date: Wed, 6 Jul 2022 10:17:23 +0800 Subject: [PATCH 1/2] [webgpu] Fix access mode for storage address space BUG Due to WGSL Spec(https://www.w3.org/TR/WGSL/#address-space), storage address space only supported read_write and read access modes. --- tfjs-backend-webgpu/src/webgpu_program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tfjs-backend-webgpu/src/webgpu_program.ts b/tfjs-backend-webgpu/src/webgpu_program.ts index 0e12193d67a..eb3561739e9 100644 --- a/tfjs-backend-webgpu/src/webgpu_program.ts +++ b/tfjs-backend-webgpu/src/webgpu_program.ts @@ -167,7 +167,7 @@ function makeShader( outShapeStrides : vec2, }; - @group(0) @binding(0) var result: array<${ + @group(0) @binding(0) var result: array<${ mapToWgslTypes(outputData.dtype, program.isVec4)}>; @group(0) @binding(2) var uniforms: Uniform; `); @@ -238,7 +238,7 @@ function makeShader( `); } else { prefixSnippets.push(` - @group(0) @binding(0) var result: array<${ + @group(0) @binding(0) var result: array<${ mapToWgslTypes(outputData.dtype, program.isVec4)}>; `); } From 2c172caac0dabc34188ff4cad1e7150f65b184ad Mon Sep 17 00:00:00 2001 From: Yunfei Hao Date: Thu, 7 Jul 2022 10:12:34 +0800 Subject: [PATCH 2/2] Change module-scope 'let' -> 'const' --- tfjs-backend-webgpu/src/matmul_packed_webgpu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts b/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts index 2c0bf26c88f..351ddd05d17 100644 --- a/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts +++ b/tfjs-backend-webgpu/src/matmul_packed_webgpu.ts @@ -177,7 +177,7 @@ export function makeMatMulVectorSource( workGroupSize[1] === 1 && workGroupSize[2] === 1, () => `A linear work group size is required. But got ${workGroupSize}.`); return ` - let TileSize = ${workGroupSize[0] * 4}; + const TileSize = ${workGroupSize[0] * 4}; var mm_Asub : array, ${workGroupSize[0]}>; ${getMainHeaderString()}