You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug fix: Correct linking for list/range iterations (#527)
Some uses of "for each" in algorithms were linking to the map
iteration definition in Infra. Fix this to point at the list iteration
definition. Today I learned: this applies to iteration over ranges
too!
Also updated coding conventions to cover these cases.
Copy file name to clipboardExpand all lines: SpecCodingConventions.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,8 @@ Example:
89
89
* Use the most specific types possible (e.g. MLOperand, not generic object).
90
90
* Use `[=this=]` to refer to the current object.
91
91
* Use `[=map/For each=] |key| → |value| of |map|` when iterating over a map, but use more specific terms for the key and value (e.g. _For each name → input of inputs:_)
92
+
* Use `[=list/For each=] |item| of |list|` when iterating over a list, but use more specific terms for the item (e.g. _For each dimension of dimensions:_)
93
+
* Use `[=list/For each=] |index| in [=the range=] X to Y, inclusive` when iterating over a numeric range; a range is implicitly an ordered set which is a type of list. Specify _inclusive_ or _exclusive_ regarding the upper bound, for clarity.
92
94
* Use "let" to introduce a variable and "set" to update a variable or assign to a property.
93
95
* Use « » notation for literal lists, which helps make it clear that they are not JavaScript arrays.
1. Let |desc| be |inputs|[0].{{MLOperand/[[descriptor]]}}.
1879
1879
1. If |axis| is greater than or equal to the [=rank=] of |desc|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1880
1880
1. Set |desc|.{{MLOperandDescriptor/dimensions}}[|axis|] to 0.
1881
-
1. [=map/For each=] |index| in [=the range=] 0 to the [=rank=] of |inputs|, exclusive:
1881
+
1. [=list/For each=] |index| in [=the range=] 0 to the [=rank=] of |inputs|, exclusive:
1882
1882
1. Let |input| be |inputs|[|index|].
1883
1883
1. If [=validating MLOperand=] given |input| and [=this=] returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1884
1884
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not equal to |inputs|[0].{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1885
-
1. [=map/For each=] |dim| in [=the range=] 0 to the [=rank=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, exclusive:
1885
+
1. [=list/For each=] |dim| in [=the range=] 0 to the [=rank=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, exclusive:
1886
1886
<div class="note">
1887
1887
If the shape of each corresponding dimension and type of the operands, except for those of the dimension given by |axis|, is not the same, fail.
1888
1888
</div>
@@ -2007,7 +2007,7 @@ Data truncation will occur when the values in the range exceed the range of the
2007
2007
1. Make a request to the underlying platform to:
2008
2008
1. Create an [=implementation-defined=] platform memory buffer the size of |size| multiplied by sizeof(|descriptor|.{{MLOperandDescriptor/dataType}}).
2009
2009
2. Store the beginning address to that memory buffer as a pointer |buffer| of the corresponding data type.
2010
-
1. [=map/For each=] |index| in [=the range=] 0 to |size|, exclusive:
2010
+
1. [=list/For each=] |index| in [=the range=] 0 to |size|, exclusive:
2011
2011
1. Set |buffer|[|index|] to |start| + (|index| * |step|).
2012
2012
1. Make a request to the underlying platform to:
2013
2013
1. Create an [=implementation-defined=] platform operand |constantImpl| to represent a constant operand, given |descriptor|.
1. Let |inputDesc| be |input|.{{MLOperand/[[descriptor]]}}.
2879
2879
1. If the sequence length of |newShape| is not equal to the [=rank=] of |inputDesc|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
2880
2880
1. Let |outputDesc| be a copy of |inputDesc|.
2881
-
1. [=map/For each=] |index| in [=the range=] 0 to the [=rank=] of |input|, exclusive:
2881
+
1. [=list/For each=] |index| in [=the range=] 0 to the [=rank=] of |input|, exclusive:
2882
2882
1. Let |size| be the |input|.{{MLOperand/shape()}}[|index|].
2883
2883
1. If |size| is not equal to 1 and not equal to |newShape|[index], then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
2884
2884
1. If |size| is equal to 1, then let |outputDesc|.{{MLOperandDescriptor/dimensions}}[|index|] be |newShape|[|index|].
@@ -3845,7 +3845,7 @@ The {{MLLayerNormalizationOptions}} members are:
3845
3845
<div class=algorithm-steps>
3846
3846
1. If the [=rank=] of |options|.{{MLLayerNormalizationOptions/scale}} is not equal to the [=list/size=] of |options|.{{MLLayerNormalizationOptions/axes}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3847
3847
1. If the [=rank=] of |options|.{{MLLayerNormalizationOptions/bias}} is not equal to the [=list/size=] of |options|.{{MLLayerNormalizationOptions/axes}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3848
-
1. [=map/For each=] |index| in [=the range=] 0 to the [=list/size=] of |options|.{{MLLayerNormalizationOptions/axes}}, exclusive:
3848
+
1. [=list/For each=] |index| in [=the range=] 0 to the [=list/size=] of |options|.{{MLLayerNormalizationOptions/axes}}, exclusive:
3849
3849
1. Let |axis| be |options|.{{MLLayerNormalizationOptions/axes}}[|index|].
3850
3850
1. If |axis| is greater or equal to the [=list/size=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3851
3851
1. Let |size| be |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[|axis|].
1. [=map/For each=] |dimension| of |desc|.{{MLOperandDescriptor/dimensions}}:
6255
+
1. [=list/For each=] |dimension| of |desc|.{{MLOperandDescriptor/dimensions}}:
6256
6256
1. Set |elementLength| to |elementLength| × |dimension|.
6257
6257
1. Let |elementSize| be the [=element size=] of one of the {{ArrayBufferView}} types that matches |desc|.{{MLOperandDescriptor/dataType}} according to [this table](#appendices-mloperanddatatype-arraybufferview-compatibility).
0 commit comments