Skip to content

Commit

Permalink
Print more info in certain asserts (#3911)
Browse files Browse the repository at this point in the history
This is useful for CQs where bots have different hardware
then devs have locally.
  • Loading branch information
greggman authored Aug 21, 2024
1 parent 32559ad commit f8472c9
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,19 @@ async function initMipGradientValuesForDevice(t: GPUTest) {
storageBuffer.destroy();
resultBuffer.destroy();

const showWeights = () => weights.map((v, i) => `${i.toString().padStart(2)}: ${v}`).join('\n');

// Validate the weights
assert(weights[0] === 0, 'weight 0 is 0');
assert(weights[kMipGradientSteps] === 1, 'top weight is 1');
assert(weights[0] === 0, `weight 0 expected 0 but was ${weights[0]}\n${showWeights()}`);
assert(
weights[kMipGradientSteps] === 1,
`top weight expected 1 but was ${weights[kMipGradientSteps]}\n${showWeights()}`
);
assert(
Math.abs(weights[kMipGradientSteps / 2] - 0.5) < 0.0001,
'middle weight is approximately 0.5'
`middle weight expected approximately 0.5 but was ${
weights[kMipGradientSteps / 2]
}\n${showWeights()}`
);

// Note: for 16 steps, these are the AMD weights
Expand Down

0 comments on commit f8472c9

Please sign in to comment.