Skip to content

Commit

Permalink
Add the largest float representable as integer (signed/unsigned) to F…
Browse files Browse the repository at this point in the history
…32 testing (execution) set (gpuweb#3942)

Co-authored-by: Peter McNeeley <[email protected]>
  • Loading branch information
2 people authored and teoxoy committed Oct 25, 2024
1 parent fa14f88 commit 07b4ee2
Show file tree
Hide file tree
Showing 41 changed files with 129 additions and 111 deletions.
220 changes: 110 additions & 110 deletions src/resources/cache/hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/resources/cache/webgpu/shader/execution/abs.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/acos.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/acosh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/asin.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/asinh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/atan.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/atanh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/bitcast.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/ceil.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/cos.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/cosh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/degrees.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/distance.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/floor.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/fract.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/frexp.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/length.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/log.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/log2.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/modf.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/pack2x16float.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/pow.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/quantizeToF16.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/radians.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/round.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/saturate.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/sign.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/sin.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/sinh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/sqrt.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/tan.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/tanh.bin
Binary file not shown.
Binary file modified src/resources/cache/webgpu/shader/execution/trunc.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 19 additions & 1 deletion src/webgpu/util/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,17 @@ export function scalarF32Range(
counts.neg_norm = counts.neg_norm === undefined ? counts.pos_norm : counts.neg_norm;
counts.neg_sub = counts.neg_sub === undefined ? counts.pos_sub : counts.neg_sub;

let special_pos: number[] = [];
// The first interior point for 'pos_norm' is at 3. Because we have two special values we start allowing these
// special values as soon as they will fit as interior values.
if (counts.pos_norm >= 4) {
special_pos = [
// Largest float as signed integer
0x4effffff,
// Largest float as unsigned integer
0x4f7fffff,
];
}
// Generating bit fields first and then converting to f32, so that the spread across the possible f32 values is more
// even. Generating against the bounds of f32 values directly results in the values being extremely biased towards the
// extremes, since they are so much larger.
Expand All @@ -980,7 +991,14 @@ export function scalarF32Range(
kBit.f32.positive.subnormal.max,
counts.pos_sub
),
...linearRange(kBit.f32.positive.min, kBit.f32.positive.max, counts.pos_norm),
...[
...linearRange(
kBit.f32.positive.min,
kBit.f32.positive.max,
counts.pos_norm - special_pos.length
),
...special_pos,
].sort((n1, n2) => n1 - n2),
].map(Math.trunc);
return bit_fields.map(reinterpretU32AsF32);
}
Expand Down

0 comments on commit 07b4ee2

Please sign in to comment.