Validation param spec system for wgblas tests — 25 param files covering
every parameter across Level 1, 2, and 3 routines, single and double
precision and complex.
Each routine declares its parameters by calling loadParam(name), which
reads a JSON file from tests/validation/params/<name>.json. The JSON
describes what values are valid, what values must throw, and boundary cases
that must not throw. runValidation drives all those cases automatically,
and the fixtures tests generate their random inputs from the same specs.
See tests/helpers/validation.js for the runner itself; this page is the
reference for the JSON schema it reads.
Each entry in invalid must cause the routine to reject with a message
containing the error string. Each entry in edge must not throw.
device.json is the one spec with no type: it only lists invalid
entries, and the device itself comes from runtimeBaselines.
type and Its Matching range Shape
range's shape depends on type — they're not interchangeable:
type
range shape
Used by
integer
{ min, max }
n, m, k, incx, incy, lda, ld (and ldb, ldc through ld)
float
{ min, max }
alpha, beta, cosine (c), s
float32array
{ elementMin, elementMax }
x, y, A, B, C
string
none — a top-level values array instead, e.g. "values": ["lower", "upper"]
uplo, trans, layout, diag, side
srotm_param
{ flags: [...], coeff: { min, max } } — srotm/drotm only
param
complex32
{ min, max }, applied to each of re/im; baseline { re, im }
alphaComplex (cscal's alpha)
complex32array
{ elementMin, elementMax }
xComplex (cscal's x)
Array specs also carry dependsOn — the scalar params (n, incx,
lda, ...) their required length is computed from. A/B/C's
dependsOn differs by BLAS level (e.g. Level 2's A depends on
["m", "n", "lda"]; Level 3's shares an inner dimension k instead).
Rather than a separate file per level, A.json carries a "level-3"
override key with its own dependsOn/invalid/edge — fetched via
loadParam('A')['level-3'] when a Level 3 routine needs it (see A.json's
own _note). No other param currently needs a level override.
Double-Precision Specs Are Derived, Not Stored
No file declares a float64array or float64 type. Asking for a name
ending in 64 — loadParam("x64"), "A64", "alpha64", "param64", … —
loads the f32 spec without the suffix and derives the f64 one on the fly
(derive64 in tests/helpers/validation.js):
float32array (and srotm_param) become float64array, float becomes
float64; everything else (dependsOn, range, scenarios) is shared.
Every invalid error message has Float32Array replaced with
Float64Array.
Vector specs gain a wrongDtypeGpuVector case and matrix specs a
wrongDtypeGpuMatrix case: a GPU-resident operand backed by a
Float32Array must be rejected with must be a Float64Array-backed ….
So one file per parameter covers both precisions, and the two can never
disagree about ranges or edge cases.
Entry Types
Entries in invalid and edge are resolved by one of three forms:
value — a literal value substituted directly (an array literal becomes
the spec's typed array, { re, im } a Complex32):
{ "value": 0, "error": "must be positive", "label": "zero" }
special — a named non-serialisable value (NaN, Infinity,
-Infinity, null, undefined, string, array, object, number):
{ "special": "NaN", "error": "must be integers", "label": "NaN" }
scenario — a named construction rule:
vectors and matrices (including complex32array): "minimal"
(exactly the minimum valid length, e.g. (n-1)*inc+1 for a vector) and
"tooShort" (one element short);
complex32: "nanRe", "nanIm", "infRe", "infIm" — a value
with one bad component;
GPU-resident dtype mismatch: "wrongDtypeGpuVector",
"wrongDtypeGpuMatrix" — added automatically to derived f64 specs (see
above) and written explicitly in xComplex.json.
{ "scenario": "tooShort", "error": "does not have enough elements", "label": "..." }
Baseline Substitution
Every scalar and string spec supplies its own explicit "baseline" value;
array specs are built as the spec's own typed array (Float32Array,
Float64Array or Complex32Array) and, without a baseline, sized
automatically from their dependsOn dimensions. For each test case,
exactly one param is replaced with the invalid or edge value while
everything else stays at baseline — isolating the parameter under test. The
device is the only param with no static baseline; it's supplied at runtime
via runtimeBaselines.
The 27 Params
27 logical parameter names, from 25 files — ldb/ldc don't get their
own file, they just reuse ld.json (loaded via loadParam("ld")) for the
same generic leading-dimension check. Each array, float and param spec
also has its derived …64 form.
Integers: n, m, k, incx, incy, lda, ldb, ldc, ld
(generic Level 3 leading-dimension check reused across routines)
Validation param spec system for wgblas tests — 25 param files covering every parameter across Level 1, 2, and 3 routines, single and double precision and complex.
Each routine declares its parameters by calling
loadParam(name), which reads a JSON file fromtests/validation/params/<name>.json. The JSON describes what values are valid, what values must throw, and boundary cases that must not throw.runValidationdrives all those cases automatically, and the fixtures tests generate their random inputs from the same specs. Seetests/helpers/validation.jsfor the runner itself; this page is the reference for the JSON schema it reads.Param Spec JSON Format
Each entry in
invalidmust cause the routine to reject with a message containing theerrorstring. Each entry inedgemust not throw.device.jsonis the one spec with notype: it only listsinvalidentries, and the device itself comes fromruntimeBaselines.typeand Its MatchingrangeShaperange's shape depends ontype— they're not interchangeable:typerangeshapeinteger{ min, max }ld)float{ min, max }c),sfloat32array{ elementMin, elementMax }stringvaluesarray instead, e.g."values": ["lower", "upper"]srotm_param{ flags: [...], coeff: { min, max } }— srotm/drotm onlycomplex32{ min, max }, applied to each ofre/im; baseline{ re, im }complex32array{ elementMin, elementMax }Array specs also carry
dependsOn— the scalar params (n,incx,lda, ...) their required length is computed from.A/B/C'sdependsOndiffers by BLAS level (e.g. Level 2'sAdepends on["m", "n", "lda"]; Level 3's shares an inner dimensionkinstead). Rather than a separate file per level,A.jsoncarries a"level-3"override key with its owndependsOn/invalid/edge— fetched vialoadParam('A')['level-3']when a Level 3 routine needs it (seeA.json's own_note). No other param currently needs a level override.Double-Precision Specs Are Derived, Not Stored
No file declares a
float64arrayorfloat64type. Asking for a name ending in64—loadParam("x64"),"A64","alpha64","param64", … — loads the f32 spec without the suffix and derives the f64 one on the fly (derive64intests/helpers/validation.js):float32array(andsrotm_param) becomefloat64array,floatbecomesfloat64; everything else (dependsOn,range, scenarios) is shared.invaliderror message hasFloat32Arrayreplaced withFloat64Array.wrongDtypeGpuVectorcase and matrix specs awrongDtypeGpuMatrixcase: a GPU-resident operand backed by aFloat32Arraymust be rejected withmust be a Float64Array-backed ….So one file per parameter covers both precisions, and the two can never disagree about ranges or edge cases.
Entry Types
Entries in
invalidandedgeare resolved by one of three forms:value — a literal value substituted directly (an array literal becomes the spec's typed array,
{ re, im }aComplex32):special — a named non-serialisable value (
NaN,Infinity,-Infinity,null,undefined,string,array,object,number):scenario — a named construction rule:
complex32array):"minimal"(exactly the minimum valid length, e.g.(n-1)*inc+1for a vector) and"tooShort"(one element short);param:"tooShort","tooLong","identity","fullMatrix","diagOne","offDiagOne";complex32:"nanRe","nanIm","infRe","infIm"— a value with one bad component;"wrongDtypeGpuVector","wrongDtypeGpuMatrix"— added automatically to derived f64 specs (see above) and written explicitly inxComplex.json.Baseline Substitution
Every scalar and string spec supplies its own explicit
"baseline"value; array specs are built as the spec's own typed array (Float32Array,Float64ArrayorComplex32Array) and, without a baseline, sized automatically from theirdependsOndimensions. For each test case, exactly one param is replaced with the invalid or edge value while everything else stays at baseline — isolating the parameter under test. The device is the only param with no static baseline; it's supplied at runtime viaruntimeBaselines.The 27 Params
27 logical parameter names, from 25 files —
ldb/ldcdon't get their own file, they just reuseld.json(loaded vialoadParam("ld")) for the same generic leading-dimension check. Each array, float andparamspec also has its derived…64form.n,m,k,incx,incy,lda,ldb,ldc,ld(generic Level 3 leading-dimension check reused across routines)alpha,beta,cosine(c),suplo,trans,layout,diag,sidex,y,A,B,CalphaComplex,xComplex(cscal)param(srotm/drotm's 5-element[flag, h11, h21, h12, h22]),device