webmachinelearning / webnn

🧠 Web Neural Network API
https://www.w3.org/TR/webnn/
Other
398 stars 48 forks source link

Apply [EnforceRange] to integer types? #562

Closed inexorabletash closed 9 months ago

inexorabletash commented 9 months ago

The prototype Chromium implementation applies [EnforceRange] to all places where integer (specifically all the unsigned long) values are used as inputs.

The spec does not currently use [EnforceRange] anywhere.

The behavior difference is that with [EnforceRange] a value outside the range results in an exception, so a value less than 0 or greater than 4294967295. Note that values are rounded so this doesn't result in an exception if e.g. 2.2 is passed, but it catches -2. I'd strongly encourage throwing (i.e. including [EnforceRange]) since conversion is otherwise non-intuitive.

Note that Chromium doesn't yet implement MLTriangularOptions which has a long (not unsigned); for consistency we'd probably want to annotate that as well.