From d6be35d5fdc1f6e63d0684a4ec0c6916c68f729d Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 25 Oct 2023 16:25:23 -0700 Subject: [PATCH] the rest --- src/common/util/util.ts | 2 +- src/unittests/floating_point.spec.ts | 30 +++++++------------ src/webgpu/shader/execution/zero_init.spec.ts | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/common/util/util.ts b/src/common/util/util.ts index 6b5396df6867..be109fc9d422 100644 --- a/src/common/util/util.ts +++ b/src/common/util/util.ts @@ -387,7 +387,7 @@ export function typedArrayParam( export function createTypedArray( type: K, - data: number[] + data: readonly number[] ): TypedArrayMap[K] { return new kTypedArrayBufferViews[type](data) as TypedArrayMap[K]; } diff --git a/src/unittests/floating_point.spec.ts b/src/unittests/floating_point.spec.ts index d016980a13f1..7eae72447624 100644 --- a/src/unittests/floating_point.spec.ts +++ b/src/unittests/floating_point.spec.ts @@ -2582,8 +2582,7 @@ g.test('atanInterval') return ulp_error * trait.oneULP(n); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.atanInterval(t.params.input); t.expect( @@ -2760,8 +2759,7 @@ g.test('cosInterval') return t.params.trait === 'f32' ? 2 ** -11 : 2 ** -7; }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.cosInterval(t.params.input); t.expect( @@ -2941,8 +2939,7 @@ g.test('expInterval') return ulp_error * trait.oneULP(x); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.expInterval(t.params.input); t.expect( @@ -3001,8 +2998,7 @@ g.test('exp2Interval') return ulp_error * trait.oneULP(x); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.exp2Interval(t.params.input); t.expect( @@ -3197,8 +3193,7 @@ g.test('inverseSqrtInterval') return 2 * trait.oneULP(n); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.inverseSqrtInterval(t.params.input); t.expect( @@ -3322,8 +3317,7 @@ g.test('logInterval') return 3 * trait.oneULP(n); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.logInterval(t.params.input); t.expect( @@ -3373,8 +3367,7 @@ g.test('log2Interval') return 3 * trait.oneULP(n); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.log2Interval(t.params.input); t.expect( @@ -3720,8 +3713,7 @@ g.test('sinInterval') return t.params.trait === 'f32' ? 2 ** -11 : 2 ** -7; }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.sinInterval(t.params.input); t.expect( @@ -3855,8 +3847,7 @@ g.test('sqrtInterval') return 2.5 * trait.oneULP(n); }; - t.params.expected = applyError(t.params.expected, error); - const expected = trait.toInterval(t.params.expected); + const expected = trait.toInterval(applyError(t.params.expected, error)); const got = trait.sqrtInterval(t.params.input); t.expect( @@ -4429,10 +4420,9 @@ g.test('divisionInterval') }; const [x, y] = t.params.input; - t.params.expected = applyError(t.params.expected, error); // Do not swizzle here, so the correct implementation under test is called. - const expected = FP[t.params.trait].toInterval(t.params.expected); + const expected = FP[t.params.trait].toInterval(applyError(t.params.expected, error)); const got = FP[t.params.trait].divisionInterval(x, y); t.expect( objectEquals(expected, got), diff --git a/src/webgpu/shader/execution/zero_init.spec.ts b/src/webgpu/shader/execution/zero_init.spec.ts index ad7b095b8995..d209c1325420 100644 --- a/src/webgpu/shader/execution/zero_init.spec.ts +++ b/src/webgpu/shader/execution/zero_init.spec.ts @@ -15,7 +15,7 @@ import { type ShaderTypeInfo = | { type: 'container'; containerType: 'array'; elementType: ShaderTypeInfo; length: number } - | { type: 'container'; containerType: 'struct'; members: ShaderTypeInfo[] } + | { type: 'container'; containerType: 'struct'; members: readonly ShaderTypeInfo[] } | { type: 'container'; containerType: keyof typeof kVectorContainerTypeInfo | keyof typeof kMatrixContainerTypeInfo;