Skip to content

Commit

Permalink
Use correctly rounded in bitcast test. (#3323)
Browse files Browse the repository at this point in the history
Use the correctly rounded helper in the bitcast test in the case where
subnormals flush to zero.
  • Loading branch information
dj2 authored Jan 25, 2024
1 parent 2f6a77f commit f8e3e18
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ T is i32, u32, f32
import { TestParams } from '../../../../../../common/framework/fixture.js';
import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../../gpu_test.js';
import { anyOf } from '../../../../../util/compare.js';
import {
TypeF16,
TypeF32,
Expand All @@ -38,6 +39,7 @@ import {
uint32ToFloat32,
u32Bits,
} from '../../../../../util/conversion.js';
import { FP } from '../../../../../util/floating_point.js';
import { scalarF32Range } from '../../../../../util/math.js';
import { ShaderBuilder, allInputSources, onlyConstInputSource, run } from '../../expression.js';

Expand Down Expand Up @@ -494,7 +496,13 @@ g.test('af_to_f32')
)
.fn(async t => {
const cases = scalarF32Range().map(u => {
return { input: abstractFloat(u), expected: f32(u) };
const res = FP['f32'].correctlyRounded(u).map(f => {
return f32(f);
});
return {
input: abstractFloat(u),
expected: anyOf(...res),
};
});

await run(t, bitcastBuilder('f32', t.params), [TypeAbstractFloat], TypeF32, t.params, cases);
Expand Down

0 comments on commit f8e3e18

Please sign in to comment.