summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/binary/af_matrix_vector_multiplication.cache.ts
blob: 4578eb0ce49b5281ecdb3df5654db17e272bc089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { FP } from '../../../../util/floating_point.js';
import { sparseMatrixF64Range, sparseVectorF64Range } from '../../../../util/math.js';
import { selectNCases } from '../case.js';
import { makeCaseCache } from '../case_cache.js';

// Cases: matCxR_vecC
const mat_vec_cases = ([2, 3, 4] as const)
  .flatMap(cols =>
    ([2, 3, 4] as const).map(rows => ({
      [`mat${cols}x${rows}_vec${cols}`]: () => {
        return selectNCases(
          'binary/af_matrix_vector_multiplication_mat_vec',
          50,
          FP.abstract.generateMatrixVectorToVectorCases(
            sparseMatrixF64Range(cols, rows),
            sparseVectorF64Range(cols),
            'finite',
            // Matrix-vector multiplication has an inherited accuracy, so abstract is only expected to be as accurate as f32
            FP.f32.multiplicationMatrixVectorInterval
          )
        );
      },
    }))
  )
  .reduce((a, b) => ({ ...a, ...b }), {});

// Cases: vecR_matCxR
const vec_mat_cases = ([2, 3, 4] as const)
  .flatMap(rows =>
    ([2, 3, 4] as const).map(cols => ({
      [`vec${rows}_mat${cols}x${rows}`]: () => {
        return selectNCases(
          'binary/af_matrix_vector_multiplication_vec_mat',
          50,
          FP.abstract.generateVectorMatrixToVectorCases(
            sparseVectorF64Range(rows),
            sparseMatrixF64Range(cols, rows),
            'finite',
            // Vector-matrix multiplication has an inherited accuracy, so abstract is only expected to be as accurate as f32
            FP.f32.multiplicationVectorMatrixInterval
          )
        );
      },
    }))
  )
  .reduce((a, b) => ({ ...a, ...b }), {});

export const d = makeCaseCache('binary/af_matrix_vector_multiplication', {
  ...mat_vec_cases,
  ...vec_mat_cases,
});