Files
sousa-gecko/testing/web-platform/tests/webnn
BruceDai aeb7574c54 Bug 2051663 [wpt PR 61003] - webnn: generate required data types and ranks JSON from the Spec, a=testonly
Automatic update from web-platform-tests
webnn: generate required data types and ranks JSON from the Spec

Previously, the per-operator minimum data type / rank limits used by the
WebNN WPT conformance harness were hand-maintained in
`minimum_datatype_set.json`, this CL replaces the hand-written file with
a generated one and adds the tooling to regenerate it:

- Add `tools/generate-required-datatypes-ranks.py`, which fetches
  `index.bs` from the WebNN spec (the `minimum_datatype_rankrange`
  branch) and parses every `tensor-limits-*` table to extract each
  operand's required data types and rank range, then writes
  `resources/required_datatypes_ranks.json`.
- Rename `minimum_datatype_set.json` -> `required_datatypes_ranks.json`
  and regenerate its contents from the spec. The new file covers
  95 operators / 184 operands.
- In `resources/utils.js`, rename `minimumDataTypeSet` ->
  `requiredDataTypesAndRanks` and `getMinimumDataTypeSetJson` ->
  `getRequiredDataTypesAndRanks`, and point the fetch at the new
  resource path.
- In `conformance_tests/is_infinite.https.any.js` and
  `is_nan.https.any.js`, update the operator argument key from
  `'input'` to `'a'` to match the spec's actual parameter name for
  these element-wise unary ops.

Bug: 434735286
Change-Id: Ib5b83c568ae34d4d8bb7c0df52f90f6f7565ef4d
Cq-Include-Trybots: luci.chromium.try​:win11-blink-rel, mac14.arm64-blink-rel, mac14-blink-rel, mac15.arm64-blink-rel, mac15-blink-rel, linux-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7936012
Commit-Queue: Hu, Ningxin <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com>
Cr-Commit-Position: refs/heads/main@{#1654974}

--

wpt-commits: 6237d26f48fa1059a5fe6855a92b9343cbc05021
wpt-pr: 61003
2026-07-10 09:22:53 +00:00
..
…
…

Web Neural Network API Test Suite

Spec: https://www.w3.org/TR/webnn/

Repo: https://github.com/webmachinelearning/webnn

Web IDL Tests

The idlharness.https.any.js test validates that the API implements the interfaces as defined in the Web IDL in the specification. A snapshot of the spec's Web IDL resides in ../interfaces/webnn.idl and is automatically daily by shared WPT infrastructure.

Validation Tests

The tests in validation_tests go beyond what can be validated from the Web IDL definitions in the spec. They ensure that parameters to the various WebNN methods are validated according to the algorithms in the spec, and that invalid inputs are rejected as specified. For example, validation_tests/matmul.https.any.js verifies that an exception is thrown if the rank of either of the input tensors is less than 2, or if the input tensor shapes are not broadcastable, etc.

Conformance Tests

The tests in conformance_tests exercise the various WebNN operators and ensure that they are behaving as expected. For example, conformance_tests/matmul.https.any.js verifies that multiplying N-dimensional matrices actually produces the expected output.

Variations

WebNN supports execution on various compute devices, e.g. CPU, GPU and NPU. The various tests make use of META: variant=?... to enable the test harness to execute the same test multiple times, with parameters specifying each device type in turn.

NOTE: The specific API for device selection is currently under debate. See: https://github.com/webmachinelearning/webnn/blob/main/device-selection-explainer.md

Globals

WebNN interfaces are exposed to both Window and Worker global contexts via the navigator.ml member. These tests make use of the .any.js convention and META: global=window,dedicatedworker to allow the test harness to execute the same test multiple times, once for each global context type.

Since executing a large number of tests consumes significant compute cycles, and since unexpected behavior differences across contexts (e.g. window vs. dedicatedworker) for individual WebNN operators (e.g. matmul()) is unlikely, most operator-specific tests only specify global=window.