From 45e2ca37a4936b32dbcd4ff695e84fb514ab88b2 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 9 Jul 2024 10:29:53 -0400 Subject: [PATCH] Add missing f32 from abstract conversion tests (#3850) Fixes #3254 --- src/resources/cache/hashes.json | 2 +- .../shader/execution/unary/f32_conversion.bin | Bin 105744 -> 138624 bytes src/webgpu/listing_meta.json | 3 + .../expression/unary/f32_conversion.cache.ts | 44 +++++++++- .../expression/unary/f32_conversion.spec.ts | 77 +++++++++++++++++- 5 files changed, 122 insertions(+), 4 deletions(-) diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index ea368705c448..e0459422560f 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -97,7 +97,7 @@ "webgpu/shader/execution/unary/f16_arithmetic.bin": "4a20db6d", "webgpu/shader/execution/unary/f16_conversion.bin": "31f72f5a", "webgpu/shader/execution/unary/f32_arithmetic.bin": "f1c311cb", - "webgpu/shader/execution/unary/f32_conversion.bin": "57dc324c", + "webgpu/shader/execution/unary/f32_conversion.bin": "7539cdb3", "webgpu/shader/execution/unary/i32_arithmetic.bin": "de945eec", "webgpu/shader/execution/unary/i32_conversion.bin": "1728a03e", "webgpu/shader/execution/unary/u32_conversion.bin": "9e6ca0ce", diff --git a/src/resources/cache/webgpu/shader/execution/unary/f32_conversion.bin b/src/resources/cache/webgpu/shader/execution/unary/f32_conversion.bin index bdcc0c72988e6a5d01923ddcc39da26aa8172951..66b2bc73f889cc03ac45cd5a116e8aaf05b5c192 100644 GIT binary patch delta 16902 zcmbtb33wGnwyrEd2q0Gtix^3W*N{L2gd`XkNwYbE$TENmBsU0xEGmoWAX{H?XO~hV z4oV_{kwrsX5EUPd`+Fb*jJ^>eohaZkjGFgp97Qy9PS>gGPWNpaeEsFzy63O|oT~1w z`m4Gxta+_z^!22;+^V>)E%la+v76W=b_bis=EAqhP?oUi>~<)pKpkT(tWWre#>F+@ z_Znd>*j=l3Y+QPAD+~Ycl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*=_{g0pyyzKtFD7${<{a*eI#g+pFH3m8w$YJC&KvI!Od`&%C!g|!;r&`gF6>>)v)l586+P{qdBln$)b>>q znKB7iCA?{?=m*c4aePjsmv}8E&o)bA){$knN=^74sgpd7&)(!XTaUUBPvMkLPD-U( z@Oo{tBad5sg49J`MR+Z?WAoX+7DILMK8q**f1ky}aM7fE$TRi$y!95?i>kKh!U$Ed z!=8nmuFICJh9@J|q>_ufWN~Nf)9zV*gL#dZ`mOiiC zW~*DnHrR{GCY6dAB9+$z zIcqc88#bfzEIsl_y;O4OHwm~~`mR2ozU`o5dd&<;mCQX9gQ_xJmr&1l^Y$7WQXmq(xJJTj^M-&-Hzf2;Ct zMrErWg{D@OqW^B+-i#))1pdYguo;z&N?Dg8Cw*JinRT4I&)2-@xP|WJK;A;nvS5hz z+>OH<6ZusymoS*slQ@am-%Y|BQD3>447ngCe)R=W7Sw5`YNj&Wn z$F=aRKg3t-Pt*!$zC1VI?HjS;p&ub$c+_67Rv%quUmNcNC32_*==Z)np}wd*nlmr- zDTS9DvsW~ZZ&!{Un`C#)e*qJT+EWAV<(q&g;hL*7eEgU=bgVtst8v9M_T6ds#&^Y{ zEPg8=i;C8NUp(|Cm2WT|Lnvs;OQ-($@kDQ8Es3Hgc0A|`{913+RNEIMLlXfR29<8# z50^Z7+eA3akhmd$*m9HQ@mWj1P?j_KQ~M~>F9|6TFk5?hZ6bn Wv;dwfUW`EK2s|4`KmQQEF!mqKm+JEX delta 31 lcmZqJ%`ssY8>8k%Ms1$WM??*Tn|(~T` @@ -46,6 +53,23 @@ const f16_mat_cases = ([2, 3, 4] as const) ) .reduce((a, b) => ({ ...a, ...b }), {}); +// Cases: abstract_float_matCxR +// Note that abstract float values may be not exactly representable in f32 +// and/or out of range. +const abstract_float_mat_cases = ([2, 3, 4] as const) + .flatMap(cols => + ([2, 3, 4] as const).map(rows => ({ + [`abstract_float_mat${cols}x${rows}`]: () => { + return FP.abstract.generateMatrixToMatrixCases( + FP.abstract.sparseMatrixRange(cols, rows), + 'finite', + FP.f32.correctlyRoundedMatrix + ); + }, + })) + ) + .reduce((a, b) => ({ ...a, ...b }), {}); + export const d = makeCaseCache('unary/f32_conversion', { bool: () => { return [ @@ -63,6 +87,13 @@ export const d = makeCaseCache('unary/f32_conversion', { return { input: i32(i), expected: FP.f32.correctlyRoundedInterval(i) }; }); }, + abstract_int: () => { + return [...fullI64Range()] + .filter(v => f32FiniteRangeInterval.contains(Number(v))) + .map(i => { + return { input: abstractInt(i), expected: FP.f32.correctlyRoundedInterval(Number(i)) }; + }); + }, f32: () => { return scalarF32Range().map(f => { return { input: f32(f), expected: FP.f32.correctlyRoundedInterval(f) }; @@ -74,6 +105,15 @@ export const d = makeCaseCache('unary/f32_conversion', { return { input: f16(f), expected: FP.f32.correctlyRoundedInterval(f) }; }); }, + // Note that abstract float values may be not exactly representable in f32. + abstract_float: () => { + return FP.abstract.generateScalarToIntervalCases( + [...FP.abstract.scalarRange()], + 'finite', + FP.f32.correctlyRoundedInterval + ); + }, ...f32_mat_cases, ...f16_mat_cases, + ...abstract_float_mat_cases, }); diff --git a/src/webgpu/shader/execution/expression/unary/f32_conversion.spec.ts b/src/webgpu/shader/execution/expression/unary/f32_conversion.spec.ts index 464fdee44e79..7a42334cb860 100644 --- a/src/webgpu/shader/execution/expression/unary/f32_conversion.spec.ts +++ b/src/webgpu/shader/execution/expression/unary/f32_conversion.spec.ts @@ -5,7 +5,7 @@ Execution Tests for the f32 conversion operations import { makeTestGroup } from '../../../../../common/framework/test_group.js'; import { GPUTest } from '../../../../gpu_test.js'; import { Type } from '../../../../util/conversion.js'; -import { ShaderBuilder, allInputSources, run } from '../expression.js'; +import { ShaderBuilder, allInputSources, run, onlyConstInputSource } from '../expression.js'; import { d } from './f32_conversion.cache.js'; import { unary } from './unary.js'; @@ -73,6 +73,32 @@ Converted to f32 await run(t, vectorizeToExpression(t.params.vectorize), [Type.i32], Type.f32, t.params, cases); }); +g.test('abstract_int') + .specURL('https://www.w3.org/TR/WGSL/#value-constructor-builtin-function') + .desc( + ` +f32(e), where e is an AbstractInt + +Converted to f32, +/-Inf if out of range +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('abstract_int'); + await run( + t, + vectorizeToExpression(t.params.vectorize), + [Type.abstractInt], + Type.f32, + t.params, + cases + ); + }); + g.test('f32') .specURL('https://www.w3.org/TR/WGSL/#value-constructor-builtin-function') .desc( @@ -166,3 +192,52 @@ g.test('f16_mat') cases ); }); + +g.test('abstract_float') + .specURL('https://www.w3.org/TR/WGSL/#value-constructor-builtin-function') + .desc( + ` +f32(e), where e is an AbstractFloat + +Correctly rounded to f32 +` + ) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('vectorize', [undefined, 2, 3, 4] as const) + ) + .fn(async t => { + const cases = await d.get('abstract_float'); + await run( + t, + vectorizeToExpression(t.params.vectorize), + [Type.abstractFloat], + Type.f32, + t.params, + cases + ); + }); + +g.test('abstract_float_mat') + .specURL('https://www.w3.org/TR/WGSL/#matrix-builtin-functions') + .desc(`AbstractFloat matrix to f32 matrix tests`) + .params(u => + u + .combine('inputSource', onlyConstInputSource) + .combine('cols', [2, 3, 4] as const) + .combine('rows', [2, 3, 4] as const) + ) + .fn(async t => { + const cols = t.params.cols; + const rows = t.params.rows; + const cases = await d.get(`abstract_float_mat${cols}x${rows}`); + await run( + t, + matrixExperession(cols, rows), + [Type.mat(cols, rows, Type.abstractFloat)], + Type.mat(cols, rows, Type.f32), + t.params, + cases + ); + });