From d24022b9da2617c51aac7b5c5086468458a76736 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 11 Mar 2024 15:49:46 -0400 Subject: [PATCH] wgsl: Implement AbstractFloat `determinant` execution tests Fixes #2523 --- src/resources/cache/hashes.json | 186 +++++++++--------- .../webgpu/shader/execution/determinant.bin | Bin 6872 -> 10368 bytes src/unittests/floating_point.spec.ts | 2 +- .../call/builtin/determinant.cache.ts | 14 ++ .../call/builtin/determinant.spec.ts | 19 +- src/webgpu/util/floating_point.ts | 5 +- 6 files changed, 124 insertions(+), 102 deletions(-) diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index d178aba9e161..49ef79d25e93 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -1,109 +1,109 @@ { - "webgpu/shader/execution/binary/af_addition.bin": "360aab58", + "webgpu/shader/execution/binary/af_addition.bin": "672ec525", "webgpu/shader/execution/binary/af_logical.bin": "4269127d", - "webgpu/shader/execution/binary/af_division.bin": "2a1ae6a9", - "webgpu/shader/execution/binary/af_matrix_addition.bin": "135913e7", - "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "83a7b6ab", - "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "5959bc9f", - "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "9c125148", - "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "efbe60ca", - "webgpu/shader/execution/binary/af_multiplication.bin": "923ed423", - "webgpu/shader/execution/binary/af_remainder.bin": "c17bb87f", - "webgpu/shader/execution/binary/af_subtraction.bin": "6457d271", + "webgpu/shader/execution/binary/af_division.bin": "6e8ad892", + "webgpu/shader/execution/binary/af_matrix_addition.bin": "32da2b7c", + "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "91deee9f", + "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "fee3b7a9", + "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "a88e71", + "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "b4125c67", + "webgpu/shader/execution/binary/af_multiplication.bin": "9169a7cc", + "webgpu/shader/execution/binary/af_remainder.bin": "cca81a43", + "webgpu/shader/execution/binary/af_subtraction.bin": "492e9fa6", "webgpu/shader/execution/binary/ai_arithmetic.bin": "f89aeb4", - "webgpu/shader/execution/binary/f16_addition.bin": "85c17d72", + "webgpu/shader/execution/binary/f16_addition.bin": "dc6254bc", "webgpu/shader/execution/binary/f16_logical.bin": "36a51091", - "webgpu/shader/execution/binary/f16_division.bin": "7c38f4b7", - "webgpu/shader/execution/binary/f16_matrix_addition.bin": "9e6258d7", - "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "916ca7e6", - "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "a4f59720", - "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "5e94030b", - "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "45b64fd9", - "webgpu/shader/execution/binary/f16_multiplication.bin": "ee7ba392", - "webgpu/shader/execution/binary/f16_remainder.bin": "ea8f78e", - "webgpu/shader/execution/binary/f16_subtraction.bin": "f5e0d152", - "webgpu/shader/execution/binary/f32_addition.bin": "d82339c6", + "webgpu/shader/execution/binary/f16_division.bin": "6d2b053a", + "webgpu/shader/execution/binary/f16_matrix_addition.bin": "341ba083", + "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "bd8dd00b", + "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "14c4703f", + "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "995297a6", + "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "195412f0", + "webgpu/shader/execution/binary/f16_multiplication.bin": "9698f93f", + "webgpu/shader/execution/binary/f16_remainder.bin": "171e75c7", + "webgpu/shader/execution/binary/f16_subtraction.bin": "7b6a942f", + "webgpu/shader/execution/binary/f32_addition.bin": "3b4de4ba", "webgpu/shader/execution/binary/f32_logical.bin": "e1d07173", - "webgpu/shader/execution/binary/f32_division.bin": "46721765", - "webgpu/shader/execution/binary/f32_matrix_addition.bin": "6fdf77f1", - "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "73520069", - "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "5ea144ba", - "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "5f5213d2", - "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "2ff78c70", - "webgpu/shader/execution/binary/f32_multiplication.bin": "3eb2748f", - "webgpu/shader/execution/binary/f32_remainder.bin": "a6728c3e", - "webgpu/shader/execution/binary/f32_subtraction.bin": "6d3120c0", + "webgpu/shader/execution/binary/f32_division.bin": "27d0e4", + "webgpu/shader/execution/binary/f32_matrix_addition.bin": "4712fb9d", + "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "7340d9ed", + "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "67894b46", + "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "90a68302", + "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "4ad5ee6", + "webgpu/shader/execution/binary/f32_multiplication.bin": "1f42db44", + "webgpu/shader/execution/binary/f32_remainder.bin": "5556d99f", + "webgpu/shader/execution/binary/f32_subtraction.bin": "54a6d2db", "webgpu/shader/execution/binary/i32_arithmetic.bin": "936d712", "webgpu/shader/execution/binary/i32_comparison.bin": "5db8f3b0", "webgpu/shader/execution/binary/u32_arithmetic.bin": "415ac05e", "webgpu/shader/execution/binary/u32_comparison.bin": "f90d60f3", - "webgpu/shader/execution/abs.bin": "3bcfb49e", - "webgpu/shader/execution/acos.bin": "86824420", - "webgpu/shader/execution/acosh.bin": "95f9a9a4", - "webgpu/shader/execution/asin.bin": "1d017518", - "webgpu/shader/execution/asinh.bin": "56df3876", - "webgpu/shader/execution/atan.bin": "6aaa6b50", - "webgpu/shader/execution/atan2.bin": "82bcc1a2", - "webgpu/shader/execution/atanh.bin": "36a1f68a", - "webgpu/shader/execution/bitcast.bin": "6b7ea46b", - "webgpu/shader/execution/ceil.bin": "7308c54f", - "webgpu/shader/execution/clamp.bin": "9bfd2fce", - "webgpu/shader/execution/cos.bin": "2fa872d3", - "webgpu/shader/execution/cosh.bin": "2e6538aa", - "webgpu/shader/execution/cross.bin": "71a7e274", - "webgpu/shader/execution/degrees.bin": "31d8728f", - "webgpu/shader/execution/determinant.bin": "399a64cb", - "webgpu/shader/execution/distance.bin": "4282ab43", - "webgpu/shader/execution/dot.bin": "b4940f90", - "webgpu/shader/execution/exp.bin": "3801f256", - "webgpu/shader/execution/exp2.bin": "fb531b99", - "webgpu/shader/execution/faceForward.bin": "ac35ad68", - "webgpu/shader/execution/floor.bin": "177dc3a6", - "webgpu/shader/execution/fma.bin": "27a3e818", - "webgpu/shader/execution/fract.bin": "8ed3cd4b", - "webgpu/shader/execution/frexp.bin": "b6d69258", - "webgpu/shader/execution/inverseSqrt.bin": "b08786b3", - "webgpu/shader/execution/ldexp.bin": "6b8bcdb3", - "webgpu/shader/execution/length.bin": "3dc4b222", - "webgpu/shader/execution/log.bin": "9219d5e4", - "webgpu/shader/execution/log2.bin": "d5ca64af", - "webgpu/shader/execution/max.bin": "9051c302", - "webgpu/shader/execution/min.bin": "e950d75f", - "webgpu/shader/execution/mix.bin": "3a720d24", - "webgpu/shader/execution/modf.bin": "ef00e883", - "webgpu/shader/execution/normalize.bin": "52231704", + "webgpu/shader/execution/abs.bin": "dff57464", + "webgpu/shader/execution/acos.bin": "13c72b8d", + "webgpu/shader/execution/acosh.bin": "f3daea94", + "webgpu/shader/execution/asin.bin": "c562907e", + "webgpu/shader/execution/asinh.bin": "721deb57", + "webgpu/shader/execution/atan.bin": "5b88238b", + "webgpu/shader/execution/atan2.bin": "418abbf", + "webgpu/shader/execution/atanh.bin": "8a76120d", + "webgpu/shader/execution/bitcast.bin": "913ebd59", + "webgpu/shader/execution/ceil.bin": "c392b09d", + "webgpu/shader/execution/clamp.bin": "2b379332", + "webgpu/shader/execution/cos.bin": "d70daf38", + "webgpu/shader/execution/cosh.bin": "3dd70510", + "webgpu/shader/execution/cross.bin": "aaf9b866", + "webgpu/shader/execution/degrees.bin": "50eed4f2", + "webgpu/shader/execution/determinant.bin": "1efb7155", + "webgpu/shader/execution/distance.bin": "6b4cb2e9", + "webgpu/shader/execution/dot.bin": "ac1a7cfa", + "webgpu/shader/execution/exp.bin": "4878be34", + "webgpu/shader/execution/exp2.bin": "2cc28715", + "webgpu/shader/execution/faceForward.bin": "180bb8cd", + "webgpu/shader/execution/floor.bin": "17dc4618", + "webgpu/shader/execution/fma.bin": "442ff796", + "webgpu/shader/execution/fract.bin": "4fd27c33", + "webgpu/shader/execution/frexp.bin": "e4230e28", + "webgpu/shader/execution/inverseSqrt.bin": "2676cff9", + "webgpu/shader/execution/ldexp.bin": "ae727461", + "webgpu/shader/execution/length.bin": "d8effb69", + "webgpu/shader/execution/log.bin": "db27f8e3", + "webgpu/shader/execution/log2.bin": "b59594e4", + "webgpu/shader/execution/max.bin": "637391a", + "webgpu/shader/execution/min.bin": "77a38ad5", + "webgpu/shader/execution/mix.bin": "b57d9e7d", + "webgpu/shader/execution/modf.bin": "83847917", + "webgpu/shader/execution/normalize.bin": "573a4169", "webgpu/shader/execution/pack2x16float.bin": "54f11627", - "webgpu/shader/execution/pow.bin": "9fdb1669", - "webgpu/shader/execution/quantizeToF16.bin": "e980118b", - "webgpu/shader/execution/radians.bin": "a676aec1", - "webgpu/shader/execution/reflect.bin": "a951c771", - "webgpu/shader/execution/refract.bin": "d8953376", - "webgpu/shader/execution/round.bin": "eee2fc9", - "webgpu/shader/execution/saturate.bin": "161df54c", - "webgpu/shader/execution/sign.bin": "9d9a22ff", - "webgpu/shader/execution/sin.bin": "29f7032a", - "webgpu/shader/execution/sinh.bin": "9d282f12", - "webgpu/shader/execution/smoothstep.bin": "f4230ffb", - "webgpu/shader/execution/sqrt.bin": "1dba9696", - "webgpu/shader/execution/step.bin": "2048f771", - "webgpu/shader/execution/tan.bin": "adc5217b", - "webgpu/shader/execution/tanh.bin": "20f7d479", - "webgpu/shader/execution/transpose.bin": "727afd91", - "webgpu/shader/execution/trunc.bin": "bc14dd25", - "webgpu/shader/execution/unpack2x16float.bin": "b8428e59", - "webgpu/shader/execution/unpack2x16snorm.bin": "e38f4982", - "webgpu/shader/execution/unpack2x16unorm.bin": "c7cdd947", - "webgpu/shader/execution/unpack4x8snorm.bin": "71e176b1", - "webgpu/shader/execution/unpack4x8unorm.bin": "5e61d6ea", - "webgpu/shader/execution/unary/af_arithmetic.bin": "29bc881a", - "webgpu/shader/execution/unary/af_assignment.bin": "33c25997", + "webgpu/shader/execution/pow.bin": "4d6b8a2d", + "webgpu/shader/execution/quantizeToF16.bin": "27f31831", + "webgpu/shader/execution/radians.bin": "64ae45ec", + "webgpu/shader/execution/reflect.bin": "3c91581c", + "webgpu/shader/execution/refract.bin": "a2d4d097", + "webgpu/shader/execution/round.bin": "d7c23e09", + "webgpu/shader/execution/saturate.bin": "a87c0a3d", + "webgpu/shader/execution/sign.bin": "a07df7f6", + "webgpu/shader/execution/sin.bin": "ffff8ea5", + "webgpu/shader/execution/sinh.bin": "6c88ea46", + "webgpu/shader/execution/smoothstep.bin": "367d70e8", + "webgpu/shader/execution/sqrt.bin": "b7d719f5", + "webgpu/shader/execution/step.bin": "20139205", + "webgpu/shader/execution/tan.bin": "706bad5e", + "webgpu/shader/execution/tanh.bin": "790da524", + "webgpu/shader/execution/transpose.bin": "75ca5973", + "webgpu/shader/execution/trunc.bin": "277331f6", + "webgpu/shader/execution/unpack2x16float.bin": "8a53b5cc", + "webgpu/shader/execution/unpack2x16snorm.bin": "c9a57618", + "webgpu/shader/execution/unpack2x16unorm.bin": "3b79443e", + "webgpu/shader/execution/unpack4x8snorm.bin": "ebac364a", + "webgpu/shader/execution/unpack4x8unorm.bin": "e16576d7", + "webgpu/shader/execution/unary/af_arithmetic.bin": "d456bf2c", + "webgpu/shader/execution/unary/af_assignment.bin": "18fdbe7d", "webgpu/shader/execution/unary/ai_arithmetic.bin": "497ec1e1", "webgpu/shader/execution/unary/ai_assignment.bin": "fc978bdd", "webgpu/shader/execution/unary/bool_conversion.bin": "bcab7d9a", - "webgpu/shader/execution/unary/f16_arithmetic.bin": "925ed6d", - "webgpu/shader/execution/unary/f16_conversion.bin": "751ff969", - "webgpu/shader/execution/unary/f32_arithmetic.bin": "b26d9187", - "webgpu/shader/execution/unary/f32_conversion.bin": "482ee20f", + "webgpu/shader/execution/unary/f16_arithmetic.bin": "512f3d36", + "webgpu/shader/execution/unary/f16_conversion.bin": "7aff8026", + "webgpu/shader/execution/unary/f32_arithmetic.bin": "40109b41", + "webgpu/shader/execution/unary/f32_conversion.bin": "a79a1a09", "webgpu/shader/execution/unary/i32_arithmetic.bin": "8f3c4616", "webgpu/shader/execution/unary/i32_conversion.bin": "972063c", "webgpu/shader/execution/unary/u32_conversion.bin": "168fcf74" diff --git a/src/resources/cache/webgpu/shader/execution/determinant.bin b/src/resources/cache/webgpu/shader/execution/determinant.bin index cef09cd67bd1e75a9778c97c4687d60e5b2c7c2a..d09c7df7e8aa5ef074640574b7a6398b17d15ec6 100644 GIT binary patch literal 10368 zcmeHMy>1*g5T3h}0j07E6<4S@7%E&kk)2AgD9Q3qVOWJb7lC6ST@)ipk#Y+^$d!Hw z1EP({Q4AM(gnIPZZOBiwN8iy8^fSGr z-_iQR_0H%QI)n9<)4yTl8(_acCXgvEqWK3j8xgvJ29Hf9jPmvz-y9Gv-ec$-a**S< zVBdP53n{;U1R2FAMzD zA<@-g9*+gyIxKX7e{)3i<|xOnfL{U6vN+7+e+&O_3;%QYAjIjUz`s5wdVRcw!S3g~ zey$VjjnCty`M*8aHgEU9+dc4gh_|y@!dvWs<7rFhxyQpP_t{6_GWg*6T3% zKC#w*)WbfE5za$%9BJRcrzv=cRd7Y#xqC5~YayZm$oge%;PKMO()jyGwW}4uK7210 zSZldf>A{uq*iJ(hJm()iw5mfb%t_ThEWW;%L_z&ByJjD*x zYL0)2`AeHqO8TP-z{1to#owR+8ua6Jaf8L)K z=lG17yc5E?Q*GIJSN!dFgYvQVZs0h=_X{jfjfl2c^VPV&9phbbd;xd@nNHdNnuoj> z-L=>4kHH>Uh-iRA+u6jf<0*E{!-SvMC&yQt+J^Hp`+ zlwpYe#OFbV`AnZP%n2g8ppz8SJZqk1n1@*XgdV1t#q-7U4D*Qo!skhfF;C6Y6k|{6 z5}(H@rg_o4@U^dN&nvZWz1O4nx}D$p9c18p@oYA8`OO&}+{_bYbQNe&if;ukz2=l0oAk@MZT@R6)%d^8 zAz$}V|JOOhC4z23Ueb@mzgPW=)+^}zmo3VF$HF&3H<6C5*HVeJBEcB))Kwrs#qoIl z4Zaw2b>NY^*6XWt(eZb$%-=1+-Lm1Fk@>^P!C!*g7M+}xCeZk*1-TOC}aord7KkxR} zoO(QTx4#|nw`0j&s&~8n(LKT6tN1&X@r8BnDCmm6Gr^ykzMS_bs50mI|L%IV@?HlT zZHTV+yPt2I9rrI?SD$O($AO;_c{0==w{De3Rw6c{tNn57w)iIN=>68lm6w~9JdkLi zy7zfY)`@)dGqkVswco~%yI}wvh@#EGlc|O$Fb+s;3>Va+(boV~D>Vff7 zv@X=fcNI7C`7UIBtQUUW>-LWa*X^q>{)AT67yjR&UdL8ijarI+&0fI6ds*!|PjzXh z>*r4zujXU5E}i>@6sPNmoj)$#!Fpz8V~pssU$ZMtbqhBx-ddg0eT?;v+|}w! z94))8;MG2u=aJWGKD6thUq|bu@8R5Ia(n34?6!he`^b2;o|Sbr^u@pCYp@$1&voaw zapUq~s6NNKoW~dDN!%qa^sS#4@S#60-dY_Gbzc0JxLD_XJOOWter5j7$b1-lKgfDD RT u - .combine('trait', ['f32', 'f16'] as const) + .combine('trait', ['f32', 'f16', 'abstract'] as const) .beginSubcases() .combineWithParams([ // Extreme values, i.e. subnormals, very large magnitudes, and those lead to diff --git a/src/webgpu/shader/execution/expression/call/builtin/determinant.cache.ts b/src/webgpu/shader/execution/expression/call/builtin/determinant.cache.ts index 379b42b3e63c..4eab44009abe 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/determinant.cache.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/determinant.cache.ts @@ -78,7 +78,21 @@ const f16_cases = ([2, 3, 4] as const) ) .reduce((a, b) => ({ ...a, ...b }), {}); +// Cases: abstract_matDxD +const abstract_cases = ([2, 3, 4] as const) + .map(dim => ({ + [`abstract_mat${dim}x${dim}`]: () => { + return FP.abstract.generateMatrixToScalarCases( + kDeterminantMatrixValues[dim], + 'finite', + FP.abstract.determinantInterval + ); + }, + })) + .reduce((a, b) => ({ ...a, ...b }), {}); + export const d = makeCaseCache('determinant', { ...f32_cases, ...f16_cases, + ...abstract_cases, }); diff --git a/src/webgpu/shader/execution/expression/call/builtin/determinant.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/determinant.spec.ts index 8b259eedb33e..638af80acaf5 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/determinant.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/determinant.spec.ts @@ -9,9 +9,9 @@ Returns the determinant of e. import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { GPUTest } from '../../../../../gpu_test.js'; import { Type } from '../../../../../util/conversion.js'; -import { allInputSources, run } from '../../expression.js'; +import { allInputSources, onlyConstInputSource, run } from '../../expression.js'; -import { builtin } from './builtin.js'; +import { abstractFloatBuiltin, builtin } from './builtin.js'; import { d } from './determinant.cache.js'; export const g = makeTestGroup(GPUTest); @@ -19,8 +19,19 @@ export const g = makeTestGroup(GPUTest); g.test('abstract_float') .specURL('https://www.w3.org/TR/WGSL/#matrix-builtin-functions') .desc(`abstract float tests`) - .params(u => u.combine('inputSource', allInputSources).combine('dimension', [2, 3, 4] as const)) - .unimplemented(); + .params(u => u.combine('inputSource', onlyConstInputSource).combine('dim', [2, 3, 4] as const)) + .fn(async t => { + const dim = t.params.dim; + const cases = await d.get(`abstract_mat${dim}x${dim}`); + await run( + t, + abstractFloatBuiltin('determinant'), + [Type.mat(dim, dim, Type.abstractFloat)], + Type.abstractFloat, + t.params, + cases + ); + }); g.test('f32') .specURL('https://www.w3.org/TR/WGSL/#matrix-builtin-functions') diff --git a/src/webgpu/util/floating_point.ts b/src/webgpu/util/floating_point.ts index 9b6fbeac39bd..36900e6da994 100644 --- a/src/webgpu/util/floating_point.ts +++ b/src/webgpu/util/floating_point.ts @@ -5128,10 +5128,7 @@ class FPAbstractTraits extends FPTraits { public readonly coshInterval = this.unimplementedScalarToInterval.bind(this, 'coshInterval'); public readonly crossInterval = this.crossIntervalImpl.bind(this); public readonly degreesInterval = this.degreesIntervalImpl.bind(this); - public readonly determinantInterval = this.unimplementedMatrixToInterval.bind( - this, - 'determinantInterval' - ); + public readonly determinantInterval = this.determinantIntervalImpl.bind(this); public readonly distanceInterval = this.unimplementedDistance.bind(this); public readonly divisionInterval = ( x: number | FPInterval,