From 79e72c09c59f8672ac3d918f2bba5e6fd7f16042 Mon Sep 17 00:00:00 2001 From: Greggman Date: Thu, 5 Dec 2024 14:18:32 +0900 Subject: [PATCH] Texture Utils, log bad weights only if debugging (#4073) --- .../expression/call/builtin/texture_utils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts index 175244697829..2e4123c6cfeb 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.ts @@ -263,14 +263,16 @@ export function graphWeights(height: number, weights: number[]) { /** * Validates the weights go from 0 to 1 in increasing order. */ -function validateWeights(stage: string, weights: number[]) { - const showWeights = () => ` +function validateWeights(t: GPUTest, stage: string, weights: number[]) { + const showWeights = t.rec.debugging + ? () => ` ${weights.map((v, i) => `${i.toString().padStart(2)}: ${v}`).join('\n')} e = expected A = actual ${graphWeights(32, weights)} -`; +` + : () => ``; // Validate the weights assert( @@ -586,8 +588,8 @@ export async function queryMipLevelMixWeightsForDevice(t: GPUTest, stage: Shader const [sampleLevelWeights, gradWeights] = unzip(result, kNumWeightTypes, 4); - validateWeights(stage, sampleLevelWeights); - validateWeights(stage, gradWeights); + validateWeights(t, stage, sampleLevelWeights); + validateWeights(t, stage, gradWeights); texture.destroy(); storageBuffer.destroy();