diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index 902b527cda9e..1bbb980a95fc 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -1,110 +1,110 @@ { - "webgpu/shader/execution/binary/af_addition.bin": "9eb45421", + "webgpu/shader/execution/binary/af_addition.bin": "2607cb36", "webgpu/shader/execution/binary/af_logical.bin": "ffb5a83f", - "webgpu/shader/execution/binary/af_division.bin": "de076f1e", - "webgpu/shader/execution/binary/af_matrix_addition.bin": "c4983e0e", - "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "9feb059b", - "webgpu/shader/execution/binary/af_multiplication.bin": "9e6ebec4", - "webgpu/shader/execution/binary/af_remainder.bin": "a32e769d", - "webgpu/shader/execution/binary/af_subtraction.bin": "61177380", - "webgpu/shader/execution/binary/f16_addition.bin": "9e9d90eb", + "webgpu/shader/execution/binary/af_division.bin": "9642be53", + "webgpu/shader/execution/binary/af_matrix_addition.bin": "28783339", + "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "fd58a70a", + "webgpu/shader/execution/binary/af_multiplication.bin": "48fb6954", + "webgpu/shader/execution/binary/af_remainder.bin": "31290507", + "webgpu/shader/execution/binary/af_subtraction.bin": "aa7a977f", + "webgpu/shader/execution/binary/f16_addition.bin": "8dee9967", "webgpu/shader/execution/binary/f16_logical.bin": "65cdc6f", - "webgpu/shader/execution/binary/f16_division.bin": "666415f0", - "webgpu/shader/execution/binary/f16_matrix_addition.bin": "4320d411", - "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "e6b3d7c2", - "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "5cbb8071", - "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "faa611c7", - "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "dc3c41eb", - "webgpu/shader/execution/binary/f16_multiplication.bin": "a5fc0a92", - "webgpu/shader/execution/binary/f16_remainder.bin": "3af0f88d", - "webgpu/shader/execution/binary/f16_subtraction.bin": "8b998e2d", - "webgpu/shader/execution/binary/f32_addition.bin": "ef32f694", + "webgpu/shader/execution/binary/f16_division.bin": "7642d7e5", + "webgpu/shader/execution/binary/f16_matrix_addition.bin": "451a2ca2", + "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "1a730f23", + "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "4e59085f", + "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "831ef7d9", + "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "9956e198", + "webgpu/shader/execution/binary/f16_multiplication.bin": "f0593e54", + "webgpu/shader/execution/binary/f16_remainder.bin": "390d16d7", + "webgpu/shader/execution/binary/f16_subtraction.bin": "89d5e800", + "webgpu/shader/execution/binary/f32_addition.bin": "204ae10f", "webgpu/shader/execution/binary/f32_logical.bin": "d40c1c0", - "webgpu/shader/execution/binary/f32_division.bin": "48e4ba24", - "webgpu/shader/execution/binary/f32_matrix_addition.bin": "c79b34d", - "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "325026ad", - "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "933a189d", - "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "6e535e50", - "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "2869473d", - "webgpu/shader/execution/binary/f32_multiplication.bin": "fc1186ab", - "webgpu/shader/execution/binary/f32_remainder.bin": "32d657b", - "webgpu/shader/execution/binary/f32_subtraction.bin": "ef9473ce", + "webgpu/shader/execution/binary/f32_division.bin": "38119537", + "webgpu/shader/execution/binary/f32_matrix_addition.bin": "ee4f7b76", + "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "1145eefd", + "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "9b0de895", + "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "a1caf103", + "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "63b9f583", + "webgpu/shader/execution/binary/f32_multiplication.bin": "8c039186", + "webgpu/shader/execution/binary/f32_remainder.bin": "7d54ad97", + "webgpu/shader/execution/binary/f32_subtraction.bin": "9080f361", "webgpu/shader/execution/binary/i32_arithmetic.bin": "90a3514a", "webgpu/shader/execution/binary/i32_comparison.bin": "840b09e6", "webgpu/shader/execution/binary/u32_arithmetic.bin": "e3f04e97", "webgpu/shader/execution/binary/u32_comparison.bin": "dc1398d3", - "webgpu/shader/execution/abs.bin": "bca87b8c", - "webgpu/shader/execution/acos.bin": "3f5603a5", - "webgpu/shader/execution/acosh.bin": "a8875a25", - "webgpu/shader/execution/asin.bin": "bab6f342", - "webgpu/shader/execution/asinh.bin": "bde88a89", - "webgpu/shader/execution/atan.bin": "af7df4af", - "webgpu/shader/execution/atan2.bin": "5cf86da4", - "webgpu/shader/execution/atanh.bin": "e458d558", - "webgpu/shader/execution/bitcast.bin": "dfb626b7", - "webgpu/shader/execution/ceil.bin": "64101beb", - "webgpu/shader/execution/clamp.bin": "3a9658bb", - "webgpu/shader/execution/cos.bin": "d9e2fdc1", - "webgpu/shader/execution/cosh.bin": "a801c990", - "webgpu/shader/execution/cross.bin": "257f0e59", - "webgpu/shader/execution/degrees.bin": "6fe31435", - "webgpu/shader/execution/determinant.bin": "db8d4a91", - "webgpu/shader/execution/distance.bin": "4fe9d05a", - "webgpu/shader/execution/dot.bin": "e6c73702", - "webgpu/shader/execution/exp.bin": "d3439761", - "webgpu/shader/execution/exp2.bin": "9478db4a", - "webgpu/shader/execution/faceForward.bin": "f89fb733", - "webgpu/shader/execution/floor.bin": "cb2425fb", - "webgpu/shader/execution/fma.bin": "3861679a", - "webgpu/shader/execution/fract.bin": "47b65795", - "webgpu/shader/execution/frexp.bin": "4060828c", - "webgpu/shader/execution/inverseSqrt.bin": "1c83865", - "webgpu/shader/execution/ldexp.bin": "8a1be293", - "webgpu/shader/execution/length.bin": "8faddca1", - "webgpu/shader/execution/log.bin": "752f08a4", - "webgpu/shader/execution/log2.bin": "28cef00f", - "webgpu/shader/execution/max.bin": "fb314c29", - "webgpu/shader/execution/min.bin": "be180118", - "webgpu/shader/execution/mix.bin": "7a4b8bf5", - "webgpu/shader/execution/modf.bin": "c2c24951", - "webgpu/shader/execution/normalize.bin": "d2216ef4", + "webgpu/shader/execution/abs.bin": "cbc5bb84", + "webgpu/shader/execution/acos.bin": "99826c48", + "webgpu/shader/execution/acosh.bin": "86faac44", + "webgpu/shader/execution/asin.bin": "1aa47c31", + "webgpu/shader/execution/asinh.bin": "3ca77d23", + "webgpu/shader/execution/atan.bin": "f3b4fad4", + "webgpu/shader/execution/atan2.bin": "695628c1", + "webgpu/shader/execution/atanh.bin": "ccac869a", + "webgpu/shader/execution/bitcast.bin": "a46c0f3c", + "webgpu/shader/execution/ceil.bin": "15ea076", + "webgpu/shader/execution/clamp.bin": "16a6107", + "webgpu/shader/execution/cos.bin": "8608aa24", + "webgpu/shader/execution/cosh.bin": "406887b3", + "webgpu/shader/execution/cross.bin": "ef98a37f", + "webgpu/shader/execution/degrees.bin": "a1f81fe8", + "webgpu/shader/execution/determinant.bin": "925aced0", + "webgpu/shader/execution/distance.bin": "1d1daa4b", + "webgpu/shader/execution/dot.bin": "5e618a78", + "webgpu/shader/execution/exp.bin": "c9ff3ee4", + "webgpu/shader/execution/exp2.bin": "124dd7fa", + "webgpu/shader/execution/faceForward.bin": "766871a0", + "webgpu/shader/execution/floor.bin": "bdbcec65", + "webgpu/shader/execution/fma.bin": "df9710d4", + "webgpu/shader/execution/fract.bin": "c6ac37ac", + "webgpu/shader/execution/frexp.bin": "4e41a6ad", + "webgpu/shader/execution/inverseSqrt.bin": "a874b8e0", + "webgpu/shader/execution/ldexp.bin": "52e686eb", + "webgpu/shader/execution/length.bin": "864e5694", + "webgpu/shader/execution/log.bin": "d86b6b5e", + "webgpu/shader/execution/log2.bin": "bb5ba2bc", + "webgpu/shader/execution/max.bin": "3e73f492", + "webgpu/shader/execution/min.bin": "6cc26be0", + "webgpu/shader/execution/mix.bin": "aca1fe65", + "webgpu/shader/execution/modf.bin": "e8dc88c2", + "webgpu/shader/execution/normalize.bin": "bd40a69", "webgpu/shader/execution/pack2x16float.bin": "d7ef3cf5", - "webgpu/shader/execution/pow.bin": "f647a4e9", - "webgpu/shader/execution/quantizeToF16.bin": "33500681", - "webgpu/shader/execution/radians.bin": "76886ba3", - "webgpu/shader/execution/reflect.bin": "fcdb2c63", - "webgpu/shader/execution/refract.bin": "2d76960c", - "webgpu/shader/execution/round.bin": "eb65ebe1", - "webgpu/shader/execution/saturate.bin": "b08d9136", - "webgpu/shader/execution/sign.bin": "30c2965f", - "webgpu/shader/execution/sin.bin": "c78bab36", - "webgpu/shader/execution/sinh.bin": "3481832c", - "webgpu/shader/execution/smoothstep.bin": "ef2a23d", - "webgpu/shader/execution/sqrt.bin": "f91009cd", - "webgpu/shader/execution/step.bin": "11f45a43", - "webgpu/shader/execution/tan.bin": "f1995462", - "webgpu/shader/execution/tanh.bin": "dff61f36", - "webgpu/shader/execution/transpose.bin": "35fe674b", - "webgpu/shader/execution/trunc.bin": "7031163e", - "webgpu/shader/execution/unpack2x16float.bin": "a70b2830", - "webgpu/shader/execution/unpack2x16snorm.bin": "bd07bdcd", - "webgpu/shader/execution/unpack2x16unorm.bin": "43581190", - "webgpu/shader/execution/unpack4x8snorm.bin": "1efe3747", - "webgpu/shader/execution/unpack4x8unorm.bin": "c5d9e041", - "webgpu/shader/execution/unary/af_arithmetic.bin": "4e096cb9", - "webgpu/shader/execution/unary/af_assignment.bin": "6abf59c7", + "webgpu/shader/execution/pow.bin": "a3f1d7bc", + "webgpu/shader/execution/quantizeToF16.bin": "cc9b060d", + "webgpu/shader/execution/radians.bin": "a4a45624", + "webgpu/shader/execution/reflect.bin": "f0edf7b6", + "webgpu/shader/execution/refract.bin": "b45fa1e3", + "webgpu/shader/execution/round.bin": "98a6ca02", + "webgpu/shader/execution/saturate.bin": "1724df20", + "webgpu/shader/execution/sign.bin": "c9304bbc", + "webgpu/shader/execution/sin.bin": "101ac9b0", + "webgpu/shader/execution/sinh.bin": "339cfa9d", + "webgpu/shader/execution/smoothstep.bin": "bd0ee34b", + "webgpu/shader/execution/sqrt.bin": "33a74294", + "webgpu/shader/execution/step.bin": "a546d1c7", + "webgpu/shader/execution/tan.bin": "98495e6c", + "webgpu/shader/execution/tanh.bin": "c8abf523", + "webgpu/shader/execution/transpose.bin": "48b9967b", + "webgpu/shader/execution/trunc.bin": "111d452f", + "webgpu/shader/execution/unpack2x16float.bin": "cafe4182", + "webgpu/shader/execution/unpack2x16snorm.bin": "9025c24a", + "webgpu/shader/execution/unpack2x16unorm.bin": "edec162d", + "webgpu/shader/execution/unpack4x8snorm.bin": "89fc1230", + "webgpu/shader/execution/unpack4x8unorm.bin": "6016b1d8", + "webgpu/shader/execution/unary/af_arithmetic.bin": "9f02dd09", + "webgpu/shader/execution/unary/af_assignment.bin": "2a53eabc", "webgpu/shader/execution/unary/bool_conversion.bin": "f37ea003", - "webgpu/shader/execution/unary/f16_arithmetic.bin": "17e0e747", - "webgpu/shader/execution/unary/f16_conversion.bin": "1d2a78dc", - "webgpu/shader/execution/unary/f32_arithmetic.bin": "8f795ec1", - "webgpu/shader/execution/unary/f32_conversion.bin": "9fe8bcdb", + "webgpu/shader/execution/unary/f16_arithmetic.bin": "5596e63b", + "webgpu/shader/execution/unary/f16_conversion.bin": "ae15a286", + "webgpu/shader/execution/unary/f32_arithmetic.bin": "1b8dfc4a", + "webgpu/shader/execution/unary/f32_conversion.bin": "3d408f29", "webgpu/shader/execution/unary/i32_arithmetic.bin": "25cf27d1", "webgpu/shader/execution/unary/i32_conversion.bin": "276dcf69", "webgpu/shader/execution/unary/u32_conversion.bin": "acac2172", "webgpu/shader/execution/unary/ai_assignment.bin": "c876d431", "webgpu/shader/execution/binary/ai_arithmetic.bin": "36a1d65b", "webgpu/shader/execution/unary/ai_arithmetic.bin": "89e34dcf", - "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "95570520", - "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "5eb914a0", - "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "c054f041" + "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "c6bc506b", + "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "a77a12e3", + "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "fb71513a" } \ No newline at end of file diff --git a/src/resources/cache/webgpu/shader/execution/binary/af_division.bin b/src/resources/cache/webgpu/shader/execution/binary/af_division.bin index af690dcfb53f..656356d32e6a 100644 Binary files a/src/resources/cache/webgpu/shader/execution/binary/af_division.bin and b/src/resources/cache/webgpu/shader/execution/binary/af_division.bin differ diff --git a/src/resources/cache/webgpu/shader/execution/binary/af_remainder.bin b/src/resources/cache/webgpu/shader/execution/binary/af_remainder.bin index b9cd253ac7ca..c45792abf49e 100644 Binary files a/src/resources/cache/webgpu/shader/execution/binary/af_remainder.bin and b/src/resources/cache/webgpu/shader/execution/binary/af_remainder.bin differ diff --git a/src/unittests/floating_point.spec.ts b/src/unittests/floating_point.spec.ts index 6120cf955150..bf6678f89bf0 100644 --- a/src/unittests/floating_point.spec.ts +++ b/src/unittests/floating_point.spec.ts @@ -22,12 +22,7 @@ import { UnitTest } from './unit_test.js'; export const g = makeTestGroup(UnitTest); -/** - * For ULP purposes, abstract float behaves like f32, so need to swizzle it in - * for expectations. - */ const kFPTraitForULP = { - abstract: 'f32', f32: 'f32', f16: 'f16', } as const; @@ -4364,13 +4359,10 @@ const kDivisionInterval64BitsNormalCases = { g.test('divisionInterval') .params(u => u - .combine('trait', ['abstract', 'f32', 'f16'] as const) + .combine('trait', ['f32', 'f16'] as const) .beginSubcases() .expandWithParams(p => { - // This is a ULP based interval, so abstract should behave like f32, so - // swizzling the trait as needed. - const trait = p.trait === 'abstract' ? 'f32' : p.trait; - const fp = FP[trait]; + const fp = FP[p.trait]; const constants = fp.constants(); // prettier-ignore return [ @@ -4387,7 +4379,7 @@ g.test('divisionInterval') { input: [-4, -2], expected: 2 }, // 64-bit normals that can not be exactly represented - ...kDivisionInterval64BitsNormalCases[trait], + ...kDivisionInterval64BitsNormalCases[p.trait], // Denominator out of range { input: [1, constants.positive.infinity], expected: kUnboundedEndpoints }, @@ -4403,10 +4395,7 @@ g.test('divisionInterval') }) ) .fn(t => { - // This is a ULP based interval, so abstract should behave like f32, so - // swizzling the trait as needed for calculating the expected result. - const trait = t.params.trait === 'abstract' ? 'f32' : t.params.trait; - const fp = FP[trait]; + const fp = FP[t.params.trait]; const error = (n: number): number => { return 2.5 * fp.oneULP(n); @@ -4414,7 +4403,6 @@ g.test('divisionInterval') const [x, y] = t.params.input; - // Do not swizzle here, so the correct implementation under test is called. const expected = FP[t.params.trait].toInterval(applyError(t.params.expected, error)); const got = FP[t.params.trait].divisionInterval(x, y); t.expect( @@ -4841,7 +4829,7 @@ const kRemainderCases = { g.test('remainderInterval') .params(u => u - .combine('trait', ['abstract', 'f32', 'f16'] as const) + .combine('trait', ['f32', 'f16'] as const) .beginSubcases() .expandWithParams(p => { const trait = kFPTraitForULP[p.trait]; diff --git a/src/webgpu/shader/execution/expression/binary/af_division.cache.ts b/src/webgpu/shader/execution/expression/binary/af_division.cache.ts index 5af293b3de28..ff2fb6a5780a 100644 --- a/src/webgpu/shader/execution/expression/binary/af_division.cache.ts +++ b/src/webgpu/shader/execution/expression/binary/af_division.cache.ts @@ -3,11 +3,13 @@ import { sparseScalarF64Range, sparseVectorF64Range } from '../../../../util/mat import { makeCaseCache } from '../case_cache.js'; const divisionVectorScalarInterval = (v: readonly number[], s: number): FPVector => { - return FP.abstract.toVector(v.map(e => FP.abstract.divisionInterval(e, s))); + // division has an ulp accuracy, so abstract is only expected to be as accurate as f32 + return FP.abstract.toVector(v.map(e => FP.f32.divisionInterval(e, s))); }; const divisionScalarVectorInterval = (s: number, v: readonly number[]): FPVector => { - return FP.abstract.toVector(v.map(e => FP.abstract.divisionInterval(s, e))); + // division has an ulp accuracy, so abstract is only expected to be as accurate as f32 + return FP.abstract.toVector(v.map(e => FP.f32.divisionInterval(s, e))); }; const scalar_cases = { @@ -16,7 +18,8 @@ const scalar_cases = { sparseScalarF64Range(), sparseScalarF64Range(), 'finite', - FP.abstract.divisionInterval + // division has an ulp accuracy, so abstract is only expected to be as accurate as f32 + FP.f32.divisionInterval ); }, }; diff --git a/src/webgpu/shader/execution/expression/binary/af_remainder.cache.ts b/src/webgpu/shader/execution/expression/binary/af_remainder.cache.ts index eba0a27760b0..4817298167ea 100644 --- a/src/webgpu/shader/execution/expression/binary/af_remainder.cache.ts +++ b/src/webgpu/shader/execution/expression/binary/af_remainder.cache.ts @@ -3,11 +3,13 @@ import { sparseScalarF64Range, sparseVectorF64Range } from '../../../../util/mat import { makeCaseCache } from '../case_cache.js'; const remainderVectorScalarInterval = (v: readonly number[], s: number): FPVector => { - return FP.abstract.toVector(v.map(e => FP.abstract.remainderInterval(e, s))); + // remainder has an inherited accuracy, so abstract is only expected to be as accurate as f32 + return FP.abstract.toVector(v.map(e => FP.f32.remainderInterval(e, s))); }; const remainderScalarVectorInterval = (s: number, v: readonly number[]): FPVector => { - return FP.abstract.toVector(v.map(e => FP.abstract.remainderInterval(s, e))); + // remainder has an inherited accuracy, so abstract is only expected to be as accurate as f32 + return FP.abstract.toVector(v.map(e => FP.f32.remainderInterval(s, e))); }; const scalar_cases = { @@ -16,7 +18,8 @@ const scalar_cases = { sparseScalarF64Range(), sparseScalarF64Range(), 'finite', - FP.abstract.remainderInterval + // remainder has an inherited accuracy, so abstract is only expected to be as accurate as f32 + FP.f32.remainderInterval ); }, }; diff --git a/src/webgpu/util/floating_point.ts b/src/webgpu/util/floating_point.ts index d56420b4d967..5f1e14fad8e0 100644 --- a/src/webgpu/util/floating_point.ts +++ b/src/webgpu/util/floating_point.ts @@ -5137,12 +5137,10 @@ class FPAbstractTraits extends FPTraits { 'determinant' ); public readonly distanceInterval = this.unimplementedDistance.bind(this); - public readonly divisionInterval = ( - x: number | FPInterval, - y: number | FPInterval - ): FPInterval => { - return this.toInterval(kF32Traits.divisionInterval(x, y)); - }; + public readonly divisionInterval = this.unimplementedScalarPairToInterval.bind( + this, + 'divisionInterval' + ); public readonly dotInterval = this.unimplementedVectorPairToInterval.bind(this, 'dotInterval'); public readonly expInterval = this.unimplementedScalarToInterval.bind(this, 'expInterval'); public readonly exp2Interval = this.unimplementedScalarToInterval.bind(this, 'exp2Interval'); @@ -5202,9 +5200,10 @@ class FPAbstractTraits extends FPTraits { 'reflectInterval' ); public readonly refractInterval = this.unimplementedRefract.bind(this); - public readonly remainderInterval = (x: number, y: number): FPInterval => { - return this.toInterval(kF32Traits.remainderInterval(x, y)); - }; + public readonly remainderInterval = this.unimplementedScalarPairToInterval.bind( + this, + 'remainderInterval' + ); public readonly roundInterval = this.roundIntervalImpl.bind(this); public readonly saturateInterval = this.saturateIntervalImpl.bind(this); public readonly signInterval = this.signIntervalImpl.bind(this);