-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wgsl: Implement AbstractFloat matrix multiplcation tests
Issue #1626
- Loading branch information
Showing
13 changed files
with
418 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,110 @@ | ||
{ | ||
"webgpu/shader/execution/binary/af_addition.bin": "9b0f1a", | ||
"webgpu/shader/execution/binary/af_addition.bin": "efe8f925", | ||
"webgpu/shader/execution/binary/af_logical.bin": "6f90d890", | ||
"webgpu/shader/execution/binary/af_division.bin": "3212306", | ||
"webgpu/shader/execution/binary/af_matrix_addition.bin": "bd0fbb9b", | ||
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "a05dabde", | ||
"webgpu/shader/execution/binary/af_multiplication.bin": "4925770d", | ||
"webgpu/shader/execution/binary/af_remainder.bin": "1f3e52da", | ||
"webgpu/shader/execution/binary/af_subtraction.bin": "8f69d801", | ||
"webgpu/shader/execution/binary/f16_addition.bin": "81009e10", | ||
"webgpu/shader/execution/binary/af_division.bin": "aaae6d8a", | ||
"webgpu/shader/execution/binary/af_matrix_addition.bin": "98481622", | ||
"webgpu/shader/execution/binary/af_matrix_subtraction.bin": "38532189", | ||
"webgpu/shader/execution/binary/af_multiplication.bin": "66e11251", | ||
"webgpu/shader/execution/binary/af_remainder.bin": "45f34746", | ||
"webgpu/shader/execution/binary/af_subtraction.bin": "7a6b6b47", | ||
"webgpu/shader/execution/binary/f16_addition.bin": "bfdca39d", | ||
"webgpu/shader/execution/binary/f16_logical.bin": "d4267b82", | ||
"webgpu/shader/execution/binary/f16_division.bin": "381b696e", | ||
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "6b642b59", | ||
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "c323687f", | ||
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "d2b84cdc", | ||
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "441b27a3", | ||
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "e0ab4084", | ||
"webgpu/shader/execution/binary/f16_multiplication.bin": "25f4d729", | ||
"webgpu/shader/execution/binary/f16_remainder.bin": "b6314e2c", | ||
"webgpu/shader/execution/binary/f16_subtraction.bin": "49f081a3", | ||
"webgpu/shader/execution/binary/f32_addition.bin": "8dfbd80b", | ||
"webgpu/shader/execution/binary/f16_division.bin": "9bb44682", | ||
"webgpu/shader/execution/binary/f16_matrix_addition.bin": "9f1c1e46", | ||
"webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "5f5c4ec7", | ||
"webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "39948cd4", | ||
"webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "8bb80013", | ||
"webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "d407640d", | ||
"webgpu/shader/execution/binary/f16_multiplication.bin": "bd275bfb", | ||
"webgpu/shader/execution/binary/f16_remainder.bin": "786010cd", | ||
"webgpu/shader/execution/binary/f16_subtraction.bin": "223a110b", | ||
"webgpu/shader/execution/binary/f32_addition.bin": "f645ccc4", | ||
"webgpu/shader/execution/binary/f32_logical.bin": "673ceb6f", | ||
"webgpu/shader/execution/binary/f32_division.bin": "15cbd8ec", | ||
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "d62c43c1", | ||
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "f43619c4", | ||
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "aa7cabf9", | ||
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "21de37e8", | ||
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "97d675d1", | ||
"webgpu/shader/execution/binary/f32_multiplication.bin": "a58e8ab6", | ||
"webgpu/shader/execution/binary/f32_remainder.bin": "b8f1dc77", | ||
"webgpu/shader/execution/binary/f32_subtraction.bin": "e5819d5f", | ||
"webgpu/shader/execution/binary/f32_division.bin": "94c79c69", | ||
"webgpu/shader/execution/binary/f32_matrix_addition.bin": "d9ef1275", | ||
"webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "4a15e2a4", | ||
"webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "c3ec9c4b", | ||
"webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "36bff663", | ||
"webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "9730cd3b", | ||
"webgpu/shader/execution/binary/f32_multiplication.bin": "cf6ccd58", | ||
"webgpu/shader/execution/binary/f32_remainder.bin": "7ae72adb", | ||
"webgpu/shader/execution/binary/f32_subtraction.bin": "2203a4a9", | ||
"webgpu/shader/execution/binary/i32_arithmetic.bin": "77c30f31", | ||
"webgpu/shader/execution/binary/i32_comparison.bin": "acb55d71", | ||
"webgpu/shader/execution/binary/u32_arithmetic.bin": "8c21844", | ||
"webgpu/shader/execution/binary/u32_comparison.bin": "47006c1e", | ||
"webgpu/shader/execution/abs.bin": "c74a3eb8", | ||
"webgpu/shader/execution/acos.bin": "326b0bf9", | ||
"webgpu/shader/execution/acosh.bin": "2ac5d999", | ||
"webgpu/shader/execution/asin.bin": "bb95c527", | ||
"webgpu/shader/execution/asinh.bin": "aab5b9a3", | ||
"webgpu/shader/execution/atan.bin": "6b121689", | ||
"webgpu/shader/execution/atan2.bin": "45c0ff60", | ||
"webgpu/shader/execution/atanh.bin": "1013c1a0", | ||
"webgpu/shader/execution/bitcast.bin": "5439e461", | ||
"webgpu/shader/execution/ceil.bin": "6d53ca77", | ||
"webgpu/shader/execution/clamp.bin": "5d410a4", | ||
"webgpu/shader/execution/cos.bin": "91102ddf", | ||
"webgpu/shader/execution/cosh.bin": "e4a88b0", | ||
"webgpu/shader/execution/cross.bin": "35931c3a", | ||
"webgpu/shader/execution/degrees.bin": "b78a7163", | ||
"webgpu/shader/execution/determinant.bin": "a79425e0", | ||
"webgpu/shader/execution/distance.bin": "86b77e5a", | ||
"webgpu/shader/execution/dot.bin": "dab272cb", | ||
"webgpu/shader/execution/exp.bin": "5b4ca455", | ||
"webgpu/shader/execution/exp2.bin": "e8bc34e", | ||
"webgpu/shader/execution/faceForward.bin": "35e9b080", | ||
"webgpu/shader/execution/floor.bin": "3cd08dfe", | ||
"webgpu/shader/execution/fma.bin": "ddb688c", | ||
"webgpu/shader/execution/fract.bin": "76aaa48c", | ||
"webgpu/shader/execution/frexp.bin": "ad859e93", | ||
"webgpu/shader/execution/inverseSqrt.bin": "4f483755", | ||
"webgpu/shader/execution/ldexp.bin": "e9a37e80", | ||
"webgpu/shader/execution/length.bin": "d977df8c", | ||
"webgpu/shader/execution/log.bin": "3da5e8b2", | ||
"webgpu/shader/execution/log2.bin": "f0dfb2eb", | ||
"webgpu/shader/execution/max.bin": "d74a67a4", | ||
"webgpu/shader/execution/min.bin": "e654ae3c", | ||
"webgpu/shader/execution/mix.bin": "6c90bd30", | ||
"webgpu/shader/execution/modf.bin": "a3babee2", | ||
"webgpu/shader/execution/normalize.bin": "f682ae69", | ||
"webgpu/shader/execution/abs.bin": "1bf6522a", | ||
"webgpu/shader/execution/acos.bin": "30abcb8b", | ||
"webgpu/shader/execution/acosh.bin": "395cbe56", | ||
"webgpu/shader/execution/asin.bin": "5011aec", | ||
"webgpu/shader/execution/asinh.bin": "fd94b235", | ||
"webgpu/shader/execution/atan.bin": "48df85d7", | ||
"webgpu/shader/execution/atan2.bin": "c97fd827", | ||
"webgpu/shader/execution/atanh.bin": "c7705636", | ||
"webgpu/shader/execution/bitcast.bin": "4fe33d33", | ||
"webgpu/shader/execution/ceil.bin": "dad575f3", | ||
"webgpu/shader/execution/clamp.bin": "92ccc487", | ||
"webgpu/shader/execution/cos.bin": "ecf40e75", | ||
"webgpu/shader/execution/cosh.bin": "e849e3a6", | ||
"webgpu/shader/execution/cross.bin": "44f8612", | ||
"webgpu/shader/execution/degrees.bin": "db4d4718", | ||
"webgpu/shader/execution/determinant.bin": "573dd1c", | ||
"webgpu/shader/execution/distance.bin": "8c24a9e4", | ||
"webgpu/shader/execution/dot.bin": "f8766c44", | ||
"webgpu/shader/execution/exp.bin": "32e505ae", | ||
"webgpu/shader/execution/exp2.bin": "8a21e8ea", | ||
"webgpu/shader/execution/faceForward.bin": "38b25c6f", | ||
"webgpu/shader/execution/floor.bin": "d78a5911", | ||
"webgpu/shader/execution/fma.bin": "db7bdd3", | ||
"webgpu/shader/execution/fract.bin": "b014e51a", | ||
"webgpu/shader/execution/frexp.bin": "8f2baee2", | ||
"webgpu/shader/execution/inverseSqrt.bin": "f9ab4896", | ||
"webgpu/shader/execution/ldexp.bin": "4a95b7a8", | ||
"webgpu/shader/execution/length.bin": "e349df50", | ||
"webgpu/shader/execution/log.bin": "8fa63c5a", | ||
"webgpu/shader/execution/log2.bin": "7728e2db", | ||
"webgpu/shader/execution/max.bin": "ef7f493f", | ||
"webgpu/shader/execution/min.bin": "c348807", | ||
"webgpu/shader/execution/mix.bin": "76a991ed", | ||
"webgpu/shader/execution/modf.bin": "b32de60a", | ||
"webgpu/shader/execution/normalize.bin": "cb156e07", | ||
"webgpu/shader/execution/pack2x16float.bin": "37c8eb38", | ||
"webgpu/shader/execution/pow.bin": "9e1e192a", | ||
"webgpu/shader/execution/quantizeToF16.bin": "5a43a691", | ||
"webgpu/shader/execution/radians.bin": "6d410c19", | ||
"webgpu/shader/execution/reflect.bin": "878366d5", | ||
"webgpu/shader/execution/refract.bin": "a47ddd59", | ||
"webgpu/shader/execution/round.bin": "9b6d3b03", | ||
"webgpu/shader/execution/saturate.bin": "16cb402d", | ||
"webgpu/shader/execution/sign.bin": "6593e1e9", | ||
"webgpu/shader/execution/sin.bin": "f318c9ad", | ||
"webgpu/shader/execution/sinh.bin": "9588cb48", | ||
"webgpu/shader/execution/smoothstep.bin": "7971703c", | ||
"webgpu/shader/execution/sqrt.bin": "e177963a", | ||
"webgpu/shader/execution/step.bin": "9ec1b79", | ||
"webgpu/shader/execution/tan.bin": "e8d70fd1", | ||
"webgpu/shader/execution/tanh.bin": "e197462f", | ||
"webgpu/shader/execution/transpose.bin": "cbd33788", | ||
"webgpu/shader/execution/trunc.bin": "e986807", | ||
"webgpu/shader/execution/unpack2x16float.bin": "6887f18d", | ||
"webgpu/shader/execution/unpack2x16snorm.bin": "2e58e7da", | ||
"webgpu/shader/execution/unpack2x16unorm.bin": "16f16906", | ||
"webgpu/shader/execution/unpack4x8snorm.bin": "545a83e7", | ||
"webgpu/shader/execution/unpack4x8unorm.bin": "e0c65898", | ||
"webgpu/shader/execution/unary/af_arithmetic.bin": "89d7f355", | ||
"webgpu/shader/execution/unary/af_assignment.bin": "89316541", | ||
"webgpu/shader/execution/pow.bin": "749b6597", | ||
"webgpu/shader/execution/quantizeToF16.bin": "8c1037ac", | ||
"webgpu/shader/execution/radians.bin": "303b1c76", | ||
"webgpu/shader/execution/reflect.bin": "93633f1d", | ||
"webgpu/shader/execution/refract.bin": "c3b07dfa", | ||
"webgpu/shader/execution/round.bin": "ac5fdd09", | ||
"webgpu/shader/execution/saturate.bin": "2b55d4dd", | ||
"webgpu/shader/execution/sign.bin": "8af6c92b", | ||
"webgpu/shader/execution/sin.bin": "99581598", | ||
"webgpu/shader/execution/sinh.bin": "5158cc47", | ||
"webgpu/shader/execution/smoothstep.bin": "cf34f5c4", | ||
"webgpu/shader/execution/sqrt.bin": "a90ea60e", | ||
"webgpu/shader/execution/step.bin": "92ba9fa4", | ||
"webgpu/shader/execution/tan.bin": "ed8d4522", | ||
"webgpu/shader/execution/tanh.bin": "b839609c", | ||
"webgpu/shader/execution/transpose.bin": "9bf5c5af", | ||
"webgpu/shader/execution/trunc.bin": "ac7f90fb", | ||
"webgpu/shader/execution/unpack2x16float.bin": "38999372", | ||
"webgpu/shader/execution/unpack2x16snorm.bin": "b10777f2", | ||
"webgpu/shader/execution/unpack2x16unorm.bin": "e4b7f246", | ||
"webgpu/shader/execution/unpack4x8snorm.bin": "2cdfff69", | ||
"webgpu/shader/execution/unpack4x8unorm.bin": "a8d09f8c", | ||
"webgpu/shader/execution/unary/af_arithmetic.bin": "84e6cf89", | ||
"webgpu/shader/execution/unary/af_assignment.bin": "83e74ad7", | ||
"webgpu/shader/execution/unary/bool_conversion.bin": "70c51822", | ||
"webgpu/shader/execution/unary/f16_arithmetic.bin": "7a269c9d", | ||
"webgpu/shader/execution/unary/f16_conversion.bin": "38fce5a9", | ||
"webgpu/shader/execution/unary/f32_arithmetic.bin": "f3f9fc0c", | ||
"webgpu/shader/execution/unary/f32_conversion.bin": "49605272", | ||
"webgpu/shader/execution/unary/f16_arithmetic.bin": "ed7541de", | ||
"webgpu/shader/execution/unary/f16_conversion.bin": "32541aa6", | ||
"webgpu/shader/execution/unary/f32_arithmetic.bin": "f9e45814", | ||
"webgpu/shader/execution/unary/f32_conversion.bin": "585bd244", | ||
"webgpu/shader/execution/unary/i32_arithmetic.bin": "cc125c13", | ||
"webgpu/shader/execution/unary/i32_conversion.bin": "fb4402f9", | ||
"webgpu/shader/execution/unary/u32_conversion.bin": "579a043f", | ||
"webgpu/shader/execution/unary/ai_assignment.bin": "954223ff", | ||
"webgpu/shader/execution/binary/ai_arithmetic.bin": "6c440be0", | ||
"webgpu/shader/execution/unary/ai_arithmetic.bin": "e89e9e9" | ||
"webgpu/shader/execution/unary/ai_arithmetic.bin": "e89e9e9", | ||
"webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "1e2e85f6", | ||
"webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "36728752", | ||
"webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "fae82a53" | ||
} |
Binary file added
BIN
+2.04 MB
src/resources/cache/webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin
Binary file not shown.
Binary file added
BIN
+1.27 MB
src/resources/cache/webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin
Binary file not shown.
Binary file added
BIN
+758 KB
src/resources/cache/webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/webgpu/shader/execution/expression/binary/af_matrix_matrix_multiplication.cache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FP } from '../../../../util/floating_point.js'; | ||
import { sparseMatrixF64Range } from '../../../../util/math.js'; | ||
import { makeCaseCache } from '../case_cache.js'; | ||
|
||
// Cases: matKxR_matCxK | ||
const mat_mat_cases = ([2, 3, 4] as const) | ||
.flatMap(k => | ||
([2, 3, 4] as const).flatMap(cols => | ||
([2, 3, 4] as const).map(rows => ({ | ||
[`mat${k}x${rows}_mat${cols}x${k}`]: () => { | ||
return FP.abstract.generateMatrixPairToMatrixCases( | ||
sparseMatrixF64Range(k, rows), | ||
sparseMatrixF64Range(cols, k), | ||
'finite', | ||
FP.abstract.multiplicationMatrixMatrixInterval | ||
); | ||
}, | ||
})) | ||
) | ||
) | ||
.reduce((a, b) => ({ ...a, ...b }), {}); | ||
|
||
export const d = makeCaseCache('binary/af_matrix_matrix_multiplication', mat_mat_cases); |
48 changes: 48 additions & 0 deletions
48
src/webgpu/shader/execution/expression/binary/af_matrix_matrix_multiplication.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export const description = ` | ||
Execution Tests for matrix-matrix AbstractFloat multiplication expression | ||
`; | ||
|
||
import { makeTestGroup } from '../../../../../common/framework/test_group.js'; | ||
import { GPUTest } from '../../../../gpu_test.js'; | ||
import { TypeAbstractFloat, TypeMat } from '../../../../util/conversion.js'; | ||
import { onlyConstInputSource, run } from '../expression.js'; | ||
|
||
import { d } from './af_matrix_matrix_multiplication.cache.js'; | ||
import { abstractFloatBinary } from './binary.js'; | ||
|
||
export const g = makeTestGroup(GPUTest); | ||
|
||
g.test('matrix_matrix') | ||
.specURL('https://www.w3.org/TR/WGSL/#floating-point-evaluation') | ||
.desc( | ||
` | ||
Expression: x * y, where x is a matrix and y is a matrix | ||
Accuracy: Correctly rounded | ||
` | ||
) | ||
.params(u => | ||
u | ||
.combine('inputSource', onlyConstInputSource) | ||
.combine('common_dim', [2, 3, 4] as const) | ||
.combine('x_rows', [2, 3, 4] as const) | ||
.combine('y_cols', [2, 3, 4] as const) | ||
) | ||
.beforeAllSubcases(t => { | ||
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] }); | ||
}) | ||
.fn(async t => { | ||
const x_cols = t.params.common_dim; | ||
const x_rows = t.params.x_rows; | ||
const y_cols = t.params.y_cols; | ||
const y_rows = t.params.common_dim; | ||
|
||
const cases = await d.get(`mat${x_cols}x${x_rows}_mat${y_cols}x${y_rows}`); | ||
await run( | ||
t, | ||
abstractFloatBinary('*'), | ||
[TypeMat(x_cols, x_rows, TypeAbstractFloat), TypeMat(y_cols, y_rows, TypeAbstractFloat)], | ||
TypeMat(y_cols, x_rows, TypeAbstractFloat), | ||
t.params, | ||
cases | ||
); | ||
}); |
40 changes: 40 additions & 0 deletions
40
src/webgpu/shader/execution/expression/binary/af_matrix_scalar_multiplication.cache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FP } from '../../../../util/floating_point.js'; | ||
import { sparseMatrixF64Range, sparseScalarF64Range } from '../../../../util/math.js'; | ||
import { makeCaseCache } from '../case_cache.js'; | ||
|
||
// Cases: matCxR_scalar | ||
const mat_scalar_cases = ([2, 3, 4] as const) | ||
.flatMap(cols => | ||
([2, 3, 4] as const).map(rows => ({ | ||
[`mat${cols}x${rows}_scalar`]: () => { | ||
return FP.abstract.generateMatrixScalarToMatrixCases( | ||
sparseMatrixF64Range(cols, rows), | ||
sparseScalarF64Range(), | ||
'finite', | ||
FP.abstract.multiplicationMatrixScalarInterval | ||
); | ||
}, | ||
})) | ||
) | ||
.reduce((a, b) => ({ ...a, ...b }), {}); | ||
|
||
// Cases: scalar_matCxR | ||
const scalar_mat_cases = ([2, 3, 4] as const) | ||
.flatMap(cols => | ||
([2, 3, 4] as const).map(rows => ({ | ||
[`scalar_mat${cols}x${rows}`]: () => { | ||
return FP.abstract.generateScalarMatrixToMatrixCases( | ||
sparseScalarF64Range(), | ||
sparseMatrixF64Range(cols, rows), | ||
'finite', | ||
FP.abstract.multiplicationScalarMatrixInterval | ||
); | ||
}, | ||
})) | ||
) | ||
.reduce((a, b) => ({ ...a, ...b }), {}); | ||
|
||
export const d = makeCaseCache('binary/af_matrix_scalar_multiplication', { | ||
...mat_scalar_cases, | ||
...scalar_mat_cases, | ||
}); |
Oops, something went wrong.