summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts')
-rw-r--r--dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts81
1 files changed, 11 insertions, 70 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts
index a64d556837..6b29aad6ad 100644
--- a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts
+++ b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/f16_subtraction.spec.ts
@@ -4,73 +4,14 @@ Execution Tests for non-matrix f16 subtraction expression
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { GPUTest } from '../../../../gpu_test.js';
-import { TypeF16, TypeVec } from '../../../../util/conversion.js';
-import { FP, FPVector } from '../../../../util/floating_point.js';
-import { sparseF16Range, sparseVectorF16Range } from '../../../../util/math.js';
-import { makeCaseCache } from '../case_cache.js';
+import { Type } from '../../../../util/conversion.js';
import { allInputSources, run } from '../expression.js';
import { binary, compoundBinary } from './binary.js';
-
-const subtractionVectorScalarInterval = (v: readonly number[], s: number): FPVector => {
- return FP.f16.toVector(v.map(e => FP.f16.subtractionInterval(e, s)));
-};
-
-const subtractionScalarVectorInterval = (s: number, v: readonly number[]): FPVector => {
- return FP.f16.toVector(v.map(e => FP.f16.subtractionInterval(s, e)));
-};
+import { d } from './f16_subtraction.cache.js';
export const g = makeTestGroup(GPUTest);
-const scalar_cases = ([true, false] as const)
- .map(nonConst => ({
- [`scalar_${nonConst ? 'non_const' : 'const'}`]: () => {
- return FP.f16.generateScalarPairToIntervalCases(
- sparseF16Range(),
- sparseF16Range(),
- nonConst ? 'unfiltered' : 'finite',
- FP.f16.subtractionInterval
- );
- },
- }))
- .reduce((a, b) => ({ ...a, ...b }), {});
-
-const vector_scalar_cases = ([2, 3, 4] as const)
- .flatMap(dim =>
- ([true, false] as const).map(nonConst => ({
- [`vec${dim}_scalar_${nonConst ? 'non_const' : 'const'}`]: () => {
- return FP.f16.generateVectorScalarToVectorCases(
- sparseVectorF16Range(dim),
- sparseF16Range(),
- nonConst ? 'unfiltered' : 'finite',
- subtractionVectorScalarInterval
- );
- },
- }))
- )
- .reduce((a, b) => ({ ...a, ...b }), {});
-
-const scalar_vector_cases = ([2, 3, 4] as const)
- .flatMap(dim =>
- ([true, false] as const).map(nonConst => ({
- [`scalar_vec${dim}_${nonConst ? 'non_const' : 'const'}`]: () => {
- return FP.f16.generateScalarVectorToVectorCases(
- sparseF16Range(),
- sparseVectorF16Range(dim),
- nonConst ? 'unfiltered' : 'finite',
- subtractionScalarVectorInterval
- );
- },
- }))
- )
- .reduce((a, b) => ({ ...a, ...b }), {});
-
-export const d = makeCaseCache('binary/f16_subtraction', {
- ...scalar_cases,
- ...vector_scalar_cases,
- ...scalar_vector_cases,
-});
-
g.test('scalar')
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation')
.desc(
@@ -87,7 +28,7 @@ Accuracy: Correctly rounded
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const'
);
- await run(t, binary('-'), [TypeF16, TypeF16], TypeF16, t.params, cases);
+ await run(t, binary('-'), [Type.f16, Type.f16], Type.f16, t.params, cases);
});
g.test('vector')
@@ -106,7 +47,7 @@ Accuracy: Correctly rounded
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const' // Using vectorize to generate vector cases based on scalar cases
);
- await run(t, binary('-'), [TypeF16, TypeF16], TypeF16, t.params, cases);
+ await run(t, binary('-'), [Type.f16, Type.f16], Type.f16, t.params, cases);
});
g.test('scalar_compound')
@@ -127,7 +68,7 @@ Accuracy: Correctly rounded
const cases = await d.get(
t.params.inputSource === 'const' ? 'scalar_const' : 'scalar_non_const'
);
- await run(t, compoundBinary('-='), [TypeF16, TypeF16], TypeF16, t.params, cases);
+ await run(t, compoundBinary('-='), [Type.f16, Type.f16], Type.f16, t.params, cases);
});
g.test('vector_scalar')
@@ -150,8 +91,8 @@ Accuracy: Correctly rounded
await run(
t,
binary('-'),
- [TypeVec(dim, TypeF16), TypeF16],
- TypeVec(dim, TypeF16),
+ [Type.vec(dim, Type.f16), Type.f16],
+ Type.vec(dim, Type.f16),
t.params,
cases
);
@@ -177,8 +118,8 @@ Accuracy: Correctly rounded
await run(
t,
compoundBinary('-='),
- [TypeVec(dim, TypeF16), TypeF16],
- TypeVec(dim, TypeF16),
+ [Type.vec(dim, Type.f16), Type.f16],
+ Type.vec(dim, Type.f16),
t.params,
cases
);
@@ -204,8 +145,8 @@ Accuracy: Correctly rounded
await run(
t,
binary('-'),
- [TypeF16, TypeVec(dim, TypeF16)],
- TypeVec(dim, TypeF16),
+ [Type.f16, Type.vec(dim, Type.f16)],
+ Type.vec(dim, Type.f16),
t.params,
cases
);