webmachinelearning / webnn

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

Make `MLOperandDescriptor.dimensions` a `FrozenArray` #670

Closed a-sully closed 5 months ago

a-sully commented 7 months ago

Here's the guidance from WebIDL which applies to MLOperandDescriptor.dimensions:

A frozen array type is a parameterized type whose values are references to objects that hold a fixed length array of unmodifiable values

This is relevant to the discussion in #666 about providing a getter to return an MLOperandDescriptor

inexorabletash commented 7 months ago

Note that per WebIDL:

Since FrozenArray<T> values are references, they are unlike sequence types, which are lists of values that are passed by value.

This is relevant for any spec text that operates on descriptor.dimensions as if it's a by-value list. My gut feeling is that most specs treat FrozenArray<T> the same as sequence<T> except that Object.freeze() will be applied at the point where a value is returned to script, but there may be more subtlety than that.

anssiko commented 6 months ago

The WebIDL spec is considering removing support for FrozenArray<T> as a dictionary member type: https://github.com/whatwg/webidl/issues/1399

We should share our use case in that issue if we feel this change is important for this API.

a-sully commented 6 months ago

Ah, thanks for the pointer. I don't think there are specific reasons why this API needs to use FrozenArray. The arguments laid out in that issue apply here, so if FrozenArray is to be removed then I think we should WontFix this issue