Skip to content

Commit

Permalink
wgsl: Add AbstractFloat mix execution tests
Browse files Browse the repository at this point in the history
Fixes #2566
  • Loading branch information
zoddicus committed Nov 23, 2023
1 parent b37df1c commit f344018
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 125 deletions.
180 changes: 90 additions & 90 deletions src/resources/cache/hashes.json
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
{
"webgpu/shader/execution/binary/af_addition.bin": "a5da1df9",
"webgpu/shader/execution/binary/af_addition.bin": "ba076909",
"webgpu/shader/execution/binary/af_logical.bin": "27d915bd",
"webgpu/shader/execution/binary/af_division.bin": "a5270697",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "62f800a8",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "9183d57f",
"webgpu/shader/execution/binary/af_multiplication.bin": "865258e7",
"webgpu/shader/execution/binary/af_remainder.bin": "4c61df7e",
"webgpu/shader/execution/binary/af_subtraction.bin": "43dd47ae",
"webgpu/shader/execution/binary/f16_addition.bin": "513d71c8",
"webgpu/shader/execution/binary/af_division.bin": "107dd6e7",
"webgpu/shader/execution/binary/af_matrix_addition.bin": "eac608aa",
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "30625b30",
"webgpu/shader/execution/binary/af_multiplication.bin": "d0b64abd",
"webgpu/shader/execution/binary/af_remainder.bin": "dcdcc401",
"webgpu/shader/execution/binary/af_subtraction.bin": "4af63ad3",
"webgpu/shader/execution/binary/f16_addition.bin": "11d1f511",
"webgpu/shader/execution/binary/f16_logical.bin": "443f9a98",
"webgpu/shader/execution/binary/f16_division.bin": "f54e29cb",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "f910cec6",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "b70ddbb2",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "62afef7a",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "29e3722d",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "f4a29ad1",
"webgpu/shader/execution/binary/f16_multiplication.bin": "9baf80a1",
"webgpu/shader/execution/binary/f16_remainder.bin": "85c74732",
"webgpu/shader/execution/binary/f16_subtraction.bin": "b06f0345",
"webgpu/shader/execution/binary/f32_addition.bin": "e0f9ce70",
"webgpu/shader/execution/binary/f16_division.bin": "f2e58c50",
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "6d9780e8",
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "c2ef2080",
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "ff00e110",
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "8648ece5",
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "af8e5074",
"webgpu/shader/execution/binary/f16_multiplication.bin": "866d7c8f",
"webgpu/shader/execution/binary/f16_remainder.bin": "5cc6603c",
"webgpu/shader/execution/binary/f16_subtraction.bin": "c0926d5d",
"webgpu/shader/execution/binary/f32_addition.bin": "97a169b1",
"webgpu/shader/execution/binary/f32_logical.bin": "47cadba6",
"webgpu/shader/execution/binary/f32_division.bin": "7005e989",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "98e53a9",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "b5c60cda",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "522a3569",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "c19e488c",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "9af1d0c3",
"webgpu/shader/execution/binary/f32_multiplication.bin": "e59c1749",
"webgpu/shader/execution/binary/f32_remainder.bin": "f0aa263b",
"webgpu/shader/execution/binary/f32_subtraction.bin": "f4bc3081",
"webgpu/shader/execution/binary/f32_division.bin": "372605df",
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "ba7fd2e1",
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "1ff984e0",
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "b5166a45",
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "3f3f1b1a",
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "2f56663c",
"webgpu/shader/execution/binary/f32_multiplication.bin": "9c3dc31c",
"webgpu/shader/execution/binary/f32_remainder.bin": "58060427",
"webgpu/shader/execution/binary/f32_subtraction.bin": "6bfb80ba",
"webgpu/shader/execution/binary/i32_arithmetic.bin": "e92caa13",
"webgpu/shader/execution/binary/i32_comparison.bin": "21f566be",
"webgpu/shader/execution/binary/u32_arithmetic.bin": "4190d758",
"webgpu/shader/execution/binary/u32_comparison.bin": "91fe8844",
"webgpu/shader/execution/abs.bin": "40c39d52",
"webgpu/shader/execution/acos.bin": "9998e303",
"webgpu/shader/execution/acosh.bin": "7636c6b9",
"webgpu/shader/execution/asin.bin": "fd7059cd",
"webgpu/shader/execution/asinh.bin": "58959a2",
"webgpu/shader/execution/atan.bin": "ed0a5fe5",
"webgpu/shader/execution/atan2.bin": "bcfaa17a",
"webgpu/shader/execution/atanh.bin": "fe79d05d",
"webgpu/shader/execution/bitcast.bin": "ab8f3a85",
"webgpu/shader/execution/ceil.bin": "82690ce1",
"webgpu/shader/execution/clamp.bin": "a30a2b8e",
"webgpu/shader/execution/cos.bin": "bf80f288",
"webgpu/shader/execution/cosh.bin": "2add503b",
"webgpu/shader/execution/cross.bin": "ce546995",
"webgpu/shader/execution/degrees.bin": "af783136",
"webgpu/shader/execution/determinant.bin": "16d6108",
"webgpu/shader/execution/distance.bin": "34788cf8",
"webgpu/shader/execution/dot.bin": "5d8d3fff",
"webgpu/shader/execution/exp.bin": "e890f3d",
"webgpu/shader/execution/exp2.bin": "80f0c788",
"webgpu/shader/execution/faceForward.bin": "4cf3e04d",
"webgpu/shader/execution/floor.bin": "4d91b147",
"webgpu/shader/execution/fma.bin": "9579e337",
"webgpu/shader/execution/fract.bin": "a1372b54",
"webgpu/shader/execution/frexp.bin": "7d140601",
"webgpu/shader/execution/inverseSqrt.bin": "515fb6e3",
"webgpu/shader/execution/ldexp.bin": "826a29a8",
"webgpu/shader/execution/length.bin": "124ac33b",
"webgpu/shader/execution/log.bin": "aad3a1a8",
"webgpu/shader/execution/log2.bin": "7ef34360",
"webgpu/shader/execution/max.bin": "69a1807",
"webgpu/shader/execution/min.bin": "8dfa353d",
"webgpu/shader/execution/mix.bin": "96c9d02d",
"webgpu/shader/execution/modf.bin": "26670f53",
"webgpu/shader/execution/normalize.bin": "60571bc4",
"webgpu/shader/execution/abs.bin": "d4df7eab",
"webgpu/shader/execution/acos.bin": "25d39e56",
"webgpu/shader/execution/acosh.bin": "6b294af7",
"webgpu/shader/execution/asin.bin": "9d346285",
"webgpu/shader/execution/asinh.bin": "19c3332d",
"webgpu/shader/execution/atan.bin": "c41e0558",
"webgpu/shader/execution/atan2.bin": "207f6c08",
"webgpu/shader/execution/atanh.bin": "2418ff4a",
"webgpu/shader/execution/bitcast.bin": "f39da065",
"webgpu/shader/execution/ceil.bin": "55bbe356",
"webgpu/shader/execution/clamp.bin": "e3afd3b8",
"webgpu/shader/execution/cos.bin": "b1f9344b",
"webgpu/shader/execution/cosh.bin": "8195c26a",
"webgpu/shader/execution/cross.bin": "65814f05",
"webgpu/shader/execution/degrees.bin": "735c1cdb",
"webgpu/shader/execution/determinant.bin": "f1b4b982",
"webgpu/shader/execution/distance.bin": "b5c1cecc",
"webgpu/shader/execution/dot.bin": "7e406c09",
"webgpu/shader/execution/exp.bin": "73800210",
"webgpu/shader/execution/exp2.bin": "13a90e73",
"webgpu/shader/execution/faceForward.bin": "419c1466",
"webgpu/shader/execution/floor.bin": "6e2b9ed8",
"webgpu/shader/execution/fma.bin": "6ff9f06a",
"webgpu/shader/execution/fract.bin": "c19ed652",
"webgpu/shader/execution/frexp.bin": "d2060f98",
"webgpu/shader/execution/inverseSqrt.bin": "5ff6ccf9",
"webgpu/shader/execution/ldexp.bin": "d187a5fc",
"webgpu/shader/execution/length.bin": "3f0e7b5a",
"webgpu/shader/execution/log.bin": "695fa792",
"webgpu/shader/execution/log2.bin": "41cfc9da",
"webgpu/shader/execution/max.bin": "875aa80e",
"webgpu/shader/execution/min.bin": "890937b7",
"webgpu/shader/execution/mix.bin": "abc617c3",
"webgpu/shader/execution/modf.bin": "d07ff54",
"webgpu/shader/execution/normalize.bin": "8f70006d",
"webgpu/shader/execution/pack2x16float.bin": "31601129",
"webgpu/shader/execution/pow.bin": "8f5de92",
"webgpu/shader/execution/quantizeToF16.bin": "9936c450",
"webgpu/shader/execution/radians.bin": "56c3610d",
"webgpu/shader/execution/reflect.bin": "61beb0cf",
"webgpu/shader/execution/refract.bin": "d0180f9b",
"webgpu/shader/execution/round.bin": "3bc78d47",
"webgpu/shader/execution/saturate.bin": "8478071d",
"webgpu/shader/execution/sign.bin": "58d75a88",
"webgpu/shader/execution/sin.bin": "b14cf00a",
"webgpu/shader/execution/sinh.bin": "a8d76c62",
"webgpu/shader/execution/smoothstep.bin": "246c76eb",
"webgpu/shader/execution/sqrt.bin": "f6c4f4c1",
"webgpu/shader/execution/step.bin": "8268c823",
"webgpu/shader/execution/tan.bin": "af3ecb02",
"webgpu/shader/execution/tanh.bin": "c22b8364",
"webgpu/shader/execution/transpose.bin": "f8663cd3",
"webgpu/shader/execution/trunc.bin": "b532e654",
"webgpu/shader/execution/unpack2x16float.bin": "67d0b480",
"webgpu/shader/execution/unpack2x16snorm.bin": "be8c0687",
"webgpu/shader/execution/unpack2x16unorm.bin": "8ef57a36",
"webgpu/shader/execution/unpack4x8snorm.bin": "a807e0f6",
"webgpu/shader/execution/unpack4x8unorm.bin": "b8ed39e8",
"webgpu/shader/execution/unary/af_arithmetic.bin": "f6181e3d",
"webgpu/shader/execution/unary/af_assignment.bin": "1da130e3",
"webgpu/shader/execution/pow.bin": "6ac15baf",
"webgpu/shader/execution/quantizeToF16.bin": "e7b1e6c",
"webgpu/shader/execution/radians.bin": "9231701a",
"webgpu/shader/execution/reflect.bin": "a87eb4bc",
"webgpu/shader/execution/refract.bin": "e7f063d0",
"webgpu/shader/execution/round.bin": "efab813f",
"webgpu/shader/execution/saturate.bin": "476aa6e5",
"webgpu/shader/execution/sign.bin": "c93c9878",
"webgpu/shader/execution/sin.bin": "d83583b1",
"webgpu/shader/execution/sinh.bin": "8ea25c9d",
"webgpu/shader/execution/smoothstep.bin": "83dc79b3",
"webgpu/shader/execution/sqrt.bin": "6a5e4c6f",
"webgpu/shader/execution/step.bin": "9043ea61",
"webgpu/shader/execution/tan.bin": "dae43ccf",
"webgpu/shader/execution/tanh.bin": "104525b7",
"webgpu/shader/execution/transpose.bin": "7539126c",
"webgpu/shader/execution/trunc.bin": "4798cd40",
"webgpu/shader/execution/unpack2x16float.bin": "75ee8b7a",
"webgpu/shader/execution/unpack2x16snorm.bin": "5f68c8bb",
"webgpu/shader/execution/unpack2x16unorm.bin": "8dee2ddb",
"webgpu/shader/execution/unpack4x8snorm.bin": "acd1c90a",
"webgpu/shader/execution/unpack4x8unorm.bin": "cdd7b213",
"webgpu/shader/execution/unary/af_arithmetic.bin": "ad7311ea",
"webgpu/shader/execution/unary/af_assignment.bin": "840fbdeb",
"webgpu/shader/execution/unary/bool_conversion.bin": "166e7b55",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "576d8432",
"webgpu/shader/execution/unary/f16_conversion.bin": "187365c9",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "abfce14d",
"webgpu/shader/execution/unary/f32_conversion.bin": "69c41336",
"webgpu/shader/execution/unary/f16_arithmetic.bin": "56ebbe09",
"webgpu/shader/execution/unary/f16_conversion.bin": "bc4f9712",
"webgpu/shader/execution/unary/f32_arithmetic.bin": "2613c79c",
"webgpu/shader/execution/unary/f32_conversion.bin": "68f6edcb",
"webgpu/shader/execution/unary/i32_arithmetic.bin": "cca83969",
"webgpu/shader/execution/unary/i32_complement.bin": "2a173277",
"webgpu/shader/execution/unary/i32_conversion.bin": "11d03e95",
Expand Down
Binary file modified src/resources/cache/webgpu/shader/execution/mix.bin
Binary file not shown.
93 changes: 83 additions & 10 deletions src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5337,13 +5337,16 @@ const kMixImpreciseIntervalCases = {
{ input: [-1.0, 1.0, 0.9], expected: [reinterpretU64AsF64(0x3fe9_9999_8000_0000n), reinterpretU64AsF64(0x3fe9_9999_c000_0000n)] }, // ~0.8

// Showing how precise and imprecise versions diff
// Note that this expectation is 0 only in f32 as 10.0 is much smaller that f32.negative.min,
// So that 10 - f32.negative.min == f32.negative.min even in f64. But for f16, there is not
// a exactly-represenatble f16 value v that make v - f16.negative.min == f16.negative.min
// in f64, in fact that require v being smaller than 2**-37.
// Note that this expectation is 0 in f32 as 10.0 is much smaller that
// f32.negative.min.
// So that 10 - f32.negative.min == -f32.negative.min even in f64.
{ input: [kValue.f32.negative.min, 10.0, 1.0], expected: 0.0 },
// -10.0 is the same, much smaller than f32.negative.min
{ input: [kValue.f32.negative.min, -10.0, 1.0], expected: 0.0 },
{ input: [kValue.f32.negative.min, 10.0, 0.5], expected: 0.0 },
{ input: [kValue.f32.negative.min, -10.0, 0.5], expected: 0.0 },
{ input: [kValue.f32.negative.min, 10.0, 5.0], expected: 0.0 },
{ input: [kValue.f32.negative.min, -10.0, 5.0], expected: 0.0 },
] as ScalarTripleToIntervalCase[],
f16: [
// [0.0, 1.0] cases
Expand All @@ -5369,13 +5372,45 @@ const kMixImpreciseIntervalCases = {
// (y - x) * 1.0, where y = -10 and x = -65504, the result is 65494 rounded to 65472 or 65504.
// The result is -65504 + 65472 = -32 or -65504 + 65504 = 0.
{ input: [kValue.f16.negative.min, -10.0, 1.0], expected: [-32, 0] },
{ input: [kValue.f16.negative.min, 10.0, 0.5], expected: kUnboundedBounds },
{ input: [kValue.f16.negative.min, -10.0, 0.5], expected: [-16, 0] },
{ input: [kValue.f16.negative.min, 10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f16.negative.min, -10.0, 5.0], expected: [-160, 0] },
] as ScalarTripleToIntervalCase[],
abstract: [
// [0.0, 1.0] cases
{ input: [0.0, 1.0, 0.1], expected: 0.1 },
{ input: [0.0, 1.0, 0.9], expected: 0.9 },
// [1.0, 0.0] cases
{ input: [1.0, 0.0, 0.1], expected: 0.9 },
{ input: [1.0, 0.0, 0.9], expected: kMinusNULPFunctions['abstract'](0.1, 2) }, // This not being 0.1 is related to https://github.com/gpuweb/cts/issues/2993
// [0.0, 10.0] cases
{ input: [0.0, 10.0, 0.1], expected: 1 },
{ input: [0.0, 10.0, 0.9], expected: 9 },
// [2.0, 10.0] cases
{ input: [2.0, 10.0, 0.1], expected: 2.8 },
{ input: [2.0, 10.0, 0.9], expected: 9.2 },
// [-1.0, 1.0] cases
{ input: [-1.0, 1.0, 0.1], expected: -0.8 },
{ input: [-1.0, 1.0, 0.9], expected: 0.8 },

// Showing how precise and imprecise versions diff
// Note that this expectation is 0 in f64 as 10.0 is much smaller that
// f64.negative.min, so that 10 - f64.negative.min == -f64.negative.min
{ input: [kValue.f64.negative.min, 10.0, 1.0], expected: 0.0 },
// -10.0 is the same, much smaller than f64.negative.min
{ input: [kValue.f64.negative.min, -10.0, 1.0], expected: 0.0 },
{ input: [kValue.f64.negative.min, 10.0, 0.5], expected: 0.0 },
{ input: [kValue.f64.negative.min, -10.0, 0.5], expected: 0.0 },
{ input: [kValue.f64.negative.min, 10.0, 5.0], expected: 0.0 },
{ input: [kValue.f64.negative.min, -10.0, 5.0], expected: 0.0 },
] as ScalarTripleToIntervalCase[],
} as const;

g.test('mixImpreciseInterval')
.params(u =>
u
.combine('trait', ['f32', 'f16'] as const)
.combine('trait', ['f32', 'f16', 'abstract'] as const)
.beginSubcases()
.expandWithParams<ScalarTripleToIntervalCase>(p => {
const trait = FP[p.trait];
Expand Down Expand Up @@ -5467,6 +5502,14 @@ const kMixPreciseIntervalCases = {
// [-1.0, 1.0] cases
{ input: [-1.0, 1.0, 0.1], expected: [reinterpretU64AsF64(0xbfe9_9999_c000_0000n), reinterpretU64AsF64(0xbfe9_9999_8000_0000n)] }, // ~-0.8
{ input: [-1.0, 1.0, 0.9], expected: [reinterpretU64AsF64(0x3fe9_9999_8000_0000n), reinterpretU64AsF64(0x3fe9_9999_c000_0000n)] }, // ~0.8

// Showing how precise and imprecise versions diff
{ input: [kValue.f32.negative.min, 10.0, 1.0], expected: 10.0 },
{ input: [kValue.f32.negative.min, -10.0, 1.0], expected: -10.0 },
{ input: [kValue.f32.negative.min, 10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f32.negative.min, -10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f32.negative.min, 10.0, 0.5], expected: kValue.f32.negative.min/2 },
{ input: [kValue.f32.negative.min, -10.0, 0.5], expected: kValue.f32.negative.min/2 },
] as ScalarTripleToIntervalCase[],
f16: [
// [0.0, 1.0] cases
Expand All @@ -5484,13 +5527,47 @@ const kMixPreciseIntervalCases = {
// [-1.0, 1.0] cases
{ input: [-1.0, 1.0, 0.1], expected: [reinterpretU64AsF64(0xbfe9_a000_0000_0000n), reinterpretU64AsF64(0xbfe9_9800_0000_0000n)] }, // ~-0.8
{ input: [-1.0, 1.0, 0.9], expected: [reinterpretU64AsF64(0x3fe9_9800_0000_0000n), reinterpretU64AsF64(0x3fe9_a000_0000_0000n)] }, // ~0.8

// Showing how precise and imprecise versions diff
{ input: [kValue.f64.negative.min, 10.0, 1.0], expected: 10.0 },
{ input: [kValue.f64.negative.min, -10.0, 1.0], expected: -10.0 },
{ input: [kValue.f64.negative.min, 10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f64.negative.min, -10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f64.negative.min, 10.0, 0.5], expected: kValue.f64.negative.min/2 },
{ input: [kValue.f64.negative.min, -10.0, 0.5], expected: kValue.f64.negative.min/2 },
] as ScalarTripleToIntervalCase[],
abstract: [
// [0.0, 1.0] cases
{ input: [0.0, 1.0, 0.1], expected: 0.1 },
{ input: [0.0, 1.0, 0.9], expected: 0.9 },
// [1.0, 0.0] cases
{ input: [1.0, 0.0, 0.1], expected: 0.9 },
{ input: [1.0, 0.0, 0.9], expected: kMinusNULPFunctions['abstract'](0.1, 2) }, // This not being 0.1 is related to https://github.com/gpuweb/cts/issues/2993
// [0.0, 10.0] cases
{ input: [0.0, 10.0, 0.1], expected: 1 },
{ input: [0.0, 10.0, 0.9], expected: 9 },
// [2.0, 10.0] cases
{ input: [2.0, 10.0, 0.1], expected: 2.8 },
{ input: [2.0, 10.0, 0.9], expected: 9.2 },
// [-1.0, 1.0] cases
{ input: [-1.0, 1.0, 0.1], expected: -0.8 },
{ input: [-1.0, 1.0, 0.9], expected: 0.8 },

// Showing how precise and imprecise versions diff
{ input: [kValue.f16.negative.min, 10.0, 1.0], expected: 10.0 },
{ input: [kValue.f16.negative.min, -10.0, 1.0], expected: -10.0 },
{ input: [kValue.f16.negative.min, 10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f16.negative.min, -10.0, 5.0], expected: kUnboundedBounds },
{ input: [kValue.f16.negative.min, 10.0, 0.5], expected: [-32747.0, 0] },
{ input: [kValue.f16.negative.min, -10.0, 0.5], expected: [-32757.0, 0] },

] as ScalarTripleToIntervalCase[],
} as const;

g.test('mixPreciseInterval')
.params(u =>
u
.combine('trait', ['f32', 'f16'] as const)
.combine('trait', ['f32', 'f16', 'abstract'] as const)
.beginSubcases()
.expandWithParams<ScalarTripleToIntervalCase>(p => {
const trait = FP[p.trait];
Expand Down Expand Up @@ -5545,10 +5622,6 @@ g.test('mixPreciseInterval')
{ input: [1.0, 0.0, constants.negative.infinity], expected: kUnboundedBounds },
{ input: [0.0, 1.0, constants.positive.infinity], expected: kUnboundedBounds },
{ input: [1.0, 0.0, constants.positive.infinity], expected: kUnboundedBounds },

// Showing how precise and imprecise versions diff
{ input: [constants.negative.min, 10.0, 1.0], expected: 10.0 },
{ input: [constants.negative.min, -10.0, 1.0], expected: -10.0 },
];
})
)
Expand Down
Loading

0 comments on commit f344018

Please sign in to comment.