Skip to content

Commit 83efdf3

Browse files
committed
CR feedback
1 parent 38ade9c commit 83efdf3

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

index.bs

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,11 +2974,11 @@ partial dictionary MLOpSupportLimits {
29742974
<dl dfn-type=dict-member dfn-for=MLCumulativeSumOptions>
29752975
: <dfn>exclusive</dfn>
29762976
::
2977-
Whether to include or exclude the current value in the output, meaning inclusive presum addition (see https://en.wikipedia.org/wiki/Prefix_sum) or exclusive post-sum addition. Given input *[1,2,3,4]*, inclusive addition would yield an output of *[1,3,6,10]* whereas exclusive would yield *[0,1,3,6]*. The default is inclusive.
2977+
Whether to include or exclude the current value in the output, meaning inclusive prefix sum or exclusive prefix sum [[Prefix-sum]]. Given input *[1,2,3,4]*, inclusive addition would yield an output of *[1,3,6,10]* whereas exclusive would yield *[0,1,3,6]*. The default is inclusive.
29782978

29792979
: <dfn>reversed</dfn>
29802980
::
2981-
Whether to reverse the summation direction along the active axis to instead start from the high coordinate to low coordinate. Given input *[1,2,3,4]*, inclusive forward addition would yield an output of *[1,3,6,10]* whereas backward summation would yield *[10,9,7,4]*. The default is exclusive.
2981+
Whether to reverse the summation direction along the active axis to instead start from the high coordinate to low coordinate. Given input *[1,2,3,4]*, inclusive forward addition would yield an output of *[1,3,6,10]* whereas backward summation would yield *[10,9,7,4]*. The default is forward.
29822982
</dl>
29832983

29842984
<div dfn-for="MLGraphBuilder/cumulativeSum(input, axis, options)" dfn-type=argument>
@@ -3236,7 +3236,7 @@ partial dictionary MLOpSupportLimits {
32363236
};
32373237
</script>
32383238

3239-
<div dfn-for="MLGraphBuilder/equal(a, b, options), MLGraphBuilder/greater(a, b, options), MLGraphBuilder/greaterOrEqual(a, b, options), MLGraphBuilder/lesser(a, b, options), MLGraphBuilder/lesserOrEqual(a, b, options), MLGraphBuilder/logicalNot(a, options)" dfn-type=argument>
3239+
<div dfn-for="MLGraphBuilder/equal(a, b, options), MLGraphBuilder/greater(a, b, options), MLGraphBuilder/greaterOrEqual(a, b, options), MLGraphBuilder/lesser(a, b, options), MLGraphBuilder/lesserOrEqual(a, b, options), MLGraphBuilder/logicalNot(a, options), MLGraphBuilder/logicalAnd(a, b, options), MLGraphBuilder/logicalOr(a, b, options), MLGraphBuilder/logicalXor(a, b, options)" dfn-type=argument>
32403240
**Arguments:**
32413241
- <dfn>a</dfn>: an {{MLOperand}}. The first input tensor.
32423242
- <dfn>b</dfn>: an {{MLOperand}}. The second input tensor when specified.
@@ -3245,7 +3245,7 @@ partial dictionary MLOpSupportLimits {
32453245
**Returns:** an {{MLOperand}}. The output tensor that contains the result of element-wise comparison of the two input tensors.
32463246
</div>
32473247

3248-
<table id=constraints-elementwise-logical class='data' link-for="MLGraphBuilder/equal(a, b, options), MLGraphBuilder/greater(a, b, options), MLGraphBuilder/greaterOrEqual(a, b, options), MLGraphBuilder/lesser(a, b, options), MLGraphBuilder/lesserOrEqual(a, b, options), MLGraphBuilder/logicalNot(a, options)">
3248+
<table id=constraints-elementwise-logical class='data' link-for="MLGraphBuilder/equal(a, b, options), MLGraphBuilder/greater(a, b, options), MLGraphBuilder/greaterOrEqual(a, b, options), MLGraphBuilder/lesser(a, b, options), MLGraphBuilder/lesserOrEqual(a, b, options), MLGraphBuilder/logicalNot(a, options), MLGraphBuilder/logicalAnd(a, b, options), MLGraphBuilder/logicalOr(a, b, options), MLGraphBuilder/logicalXor(a, b, options)">
32493249
<caption>Constraints for element-wise logical options</caption>
32503250
<thead>
32513251
<tr>
@@ -3313,9 +3313,9 @@ partial dictionary MLOpSupportLimits {
33133313
- *lesser*: Compare if the values of the first input tensor is lesser, element-wise.
33143314
- *lesserOrEqual*: Compare if the values of the first input tensor is lesser or equal, element-wise.
33153315
- *logicalNot*: Invert the values of the input tensor to values 0 or 1, element-wise. Specifically, when the input value is non-zero, invert it to 0. Conversely, for a zero input value, invert it to 1.
3316-
- *logicalAnd*: Compute the logical *and* operator, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
3317-
- *logicalOr*: Compute the logical *or* operator, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
3318-
- *logicalXor*: Compute the logical *xor* operator, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
3316+
- *logicalAnd*: Compute the logical *and* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
3317+
- *logicalOr*: Compute the logical *or* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
3318+
- *logicalXor*: Compute the logical *xor* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1.
33193319
</div>
33203320

33213321
<div class="note">
@@ -3328,7 +3328,7 @@ Although operations {{MLGraphBuilder/greaterOrEqual()}} and {{MLGraphBuilder/les
33283328
</summary>
33293329
1. [=Assert=]: |op| is one of "equal", "notEqual", "greater", "greaterOrEqual", "lesser", "lesserOrEqual", "logicalNot", "logicalAnd", "logicalOr", "logicalXor".
33303330
1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
3331-
1. If |op| is "logicalNot":
3331+
1. If |op| is one of "logicalNot", "logicalAnd", "logicalOr", "logicalXor":
33323332
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |a| returns false, then [=exception/throw=] a {{TypeError}}.
33333333
1. If |a|'s [=MLOperand/dataType=] is not {{MLOperandDataType/"uint8"}}, then [=exception/throw=] a {{TypeError}}.
33343334
1. Let |outputShape| be a [=list/clone=] of |a|'s [=MLOperand/shape=].
@@ -3640,7 +3640,7 @@ partial dictionary MLOpSupportLimits {
36403640

36413641
<div algorithm>
36423642
The <dfn method for=MLGraphBuilder>sign(|input|, |options|)</dfn> method steps are:
3643-
1. Let |output| be the result of running the [=MLGraphBuilder/element-wise-unary-op | create element-wise unary operation=] given "sign", |input|, signed types « {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}, {{MLOperandDataType/"int8"}} », and |options|.
3643+
1. Let |output| be the result of running the [=MLGraphBuilder/element-wise-unary-op | create element-wise unary operation=] given "sign", |input|, « {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}, {{MLOperandDataType/"int8"}} », and |options|.
36443644
1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error.
36453645
1. Return |output|.
36463646
</div>
@@ -3685,7 +3685,7 @@ partial dictionary MLOpSupportLimits {
36853685

36863686

36873687
### dequantizeLinear ### {#api-mlgraphbuilder-dequantizelinear}
3688-
Dequantizes an integer tensor to floating point space using the scale and zero-point bias, where `output = (input - zeroPoint) * scale`.
3688+
Dequantizes an integer tensor to floating point tensor using the scale and zero-point bias, where `output = (input - zeroPoint) * scale`.
36893689

36903690
TODO: Elaborate on blockwise broadcasting - The operation will be [=broadcast=] according to [[!numpy-broadcasting-rule]]. The input tensors must be [=bidirectionally broadcastable=]. The [=MLOperand/rank=] of the output tensor is the maximum [=MLOperand/rank=] of the input tensors. For each dimension of the output tensor, its size is the maximum size along that dimension of the input tensors, and each dimension must be blockwise compatible with the output (e.g. given an input shape *[12]*, scales of the following shapes are blockwise compatible {*[1]*, *[3]*, *[4]*, *[6]*, *[12]*} as they are all multiples of the input dimensions, but a shape of *[5]* would not be).
36913691

@@ -3712,8 +3712,8 @@ partial dictionary MLOpSupportLimits {
37123712
<div dfn-for="MLGraphBuilder/dequantizeLinear(input, scale, zeroPoint, options)" dfn-type=argument>
37133713
**Arguments:**
37143714
- <dfn>input</dfn>: an {{MLOperand}}. The input tensor.
3715-
- <dfn>scale</dfn>: an {{MLOperand}}. The scale tensor to multiply each input value by after adjusting by the zero point.
3716-
- <dfn>zeroPoint</dfn>: an {{MLOperand}}. The zero point tensor to subtract from each input value.
3715+
- <dfn>scale</dfn>: an {{MLOperand}}. The scale tensor to multiply each input value by after adjusting by the zero point. It has the same [=MLOperand/rank=] as the input, and its [=MLOperand/shape=] must evenly divide into the input [=MLOperand/shape=].
3716+
- <dfn>zeroPoint</dfn>: an {{MLOperand}}. The zero point tensor to subtract from each input value. It has the same [=MLOperand/shape=] as the scale.
37173717
- <dfn>options</dfn>: an {{MLOperatorOptions}}. Specifies the optional parameters of the operation.
37183718

37193719
**Returns:** an {{MLOperand}}. The output tensor that contains the dequantized values.
@@ -3730,18 +3730,18 @@ partial dictionary MLOpSupportLimits {
37303730
</thead>
37313731
<tr>
37323732
<td>{{input}}</td>
3733-
<td>{{MLOperandDataType/"uint4"}}, {{MLOperandDataType/"uint8"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int32"}}</td>
3734-
<td>N</td>
3733+
<td>{{MLOperandDataType/"uint8"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int32"}}</td>
3734+
<td>[=/any rank|N=]</td>
37353735
</tr>
37363736
<tr>
37373737
<td>{{scale}}</td>
37383738
<td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}</td>
3739-
<td>0 to {{input}}'s [=MLOperand/rank=]</td>
3739+
<td>[=/same rank as|same as=] {{input}}</td>
37403740
</tr>
37413741
<tr>
37423742
<td>{{zeroPoint}}</td>
37433743
<td>[=/same type as|same as=] {{input}}</td>
3744-
<td>0 to {{input}}'s [=MLOperand/rank=]</td>
3744+
<td>[=/same rank as|same as=] {{input}}</td>
37453745
</tr>
37463746
<tr>
37473747
<td>*output*</td>
@@ -3774,7 +3774,11 @@ partial dictionary MLOpSupportLimits {
37743774
</summary>
37753775
1. If [=this=].{{MLGraphBuilder/[[hasBuilt]]}} is true, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
37763776
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input|, |scale|, and |zeroPoint| returns false, then [=exception/throw=] a {{TypeError}}.
3777-
TODO: Add validation for scale and zero point shape.
3777+
1. If |scale|'s [=MLOperand/rank=] or |zeroPoint|'s [=MLOperand/rank=] mismatches |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
3778+
1. If |scale|'s [=MLOperand/shape=] mismatches |zeroPoint|'s [=MLOperand/shape=], then [=exception/throw=] a {{TypeError}}.
3779+
1. [=list/For each=] |axis| in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive:
3780+
1. If |scale|'s [=MLOperand/shape=][|axis|] is not exactly divisible into |input|'s [=MLOperand/shape=][|axis|], then [=exception/throw=] a {{TypeError}}.
3781+
1. If |zeroPoint|'s [=MLOperand/shape=][|axis|] is not exactly divisible into |input|'s [=MLOperand/shape=][|axis|], then [=exception/throw=] a {{TypeError}}.
37783782
</details>
37793783

37803784
<div class="note">
@@ -3790,7 +3794,7 @@ partial dictionary MLOpSupportLimits {
37903794

37913795

37923796
### quantizeLinear ### {#api-mlgraphbuilder-quantizelinear}
3793-
Quantizes a floating point tensor to integer point space using the scale and zero-point bias, where `output = clamp(roundToNearestEvens(input / scale) + zeroPoint, 0, 255)`.
3797+
Quantizes a floating point tensor to integer tensor using the scale and zero-point bias, where `output = clamp(roundToNearestEvens(input / scale) + zeroPoint, 0, 255)`.
37943798

37953799
TODO: Elaborate on blockwise broadcasting - The operation will be [=broadcast=] according to [[!numpy-broadcasting-rule]]. The input tensors must be [=bidirectionally broadcastable=]. The [=MLOperand/rank=] of the output tensor is the maximum [=MLOperand/rank=] of the input tensors. For each dimension of the output tensor, its size is the maximum size along that dimension of the input tensors, and each dimension must be blockwise compatible with the output (e.g. given an input shape *[12]*, scales of the following shapes are blockwise compatible {*[1]*, *[3]*, *[4]*, *[6]*, *[12]*} as they are all multiples of the input dimensions, but a shape of *[5]* would not be).
37963800

@@ -3817,8 +3821,8 @@ partial dictionary MLOpSupportLimits {
38173821
<div dfn-for="MLGraphBuilder/quantizeLinear(input, scale, zeroPoint, options)" dfn-type=argument>
38183822
**Arguments:**
38193823
- <dfn>input</dfn>: an {{MLOperand}}. The condition tensor.
3820-
- <dfn>scale</dfn>: an {{MLOperand}}. The scale tensor to multiply each input value by after adjusting by the zero point.
3821-
- <dfn>zeroPoint</dfn>: an {{MLOperand}}. The zero point tensor to subtract from each input value.
3824+
- <dfn>scale</dfn>: an {{MLOperand}}. The scale tensor to divide each input value by after adjusting by the zero point. It has the same [=MLOperand/rank=] as the input, and its [=MLOperand/shape=] must evenly divide into the input [=MLOperand/shape=].
3825+
- <dfn>zeroPoint</dfn>: an {{MLOperand}}. The zero point tensor to add to each rescaled input value. It has the same [=MLOperand/shape=] as the scale.
38223826
- <dfn>options</dfn>: an {{MLOperatorOptions}}. Specifies the optional parameters of the operation.
38233827

38243828
**Returns:** an {{MLOperand}}. The output tensor that contains the quantized values.
@@ -3836,17 +3840,17 @@ partial dictionary MLOpSupportLimits {
38363840
<tr>
38373841
<td>{{input}}</td>
38383842
<td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}</td>
3839-
<td>N</td>
3843+
<td>[=/any rank|N=]</td>
38403844
</tr>
38413845
<tr>
38423846
<td>{{scale}}</td>
38433847
<td>[=/same type as|same as=] {{input}}</td>
3844-
<td>0 to {{input}}'s [=MLOperand/rank=]</td>
3848+
<td>[=/same rank as|same as=] {{input}}</td>
38453849
</tr>
38463850
<tr>
38473851
<td>{{zeroPoint}}</td>
3848-
<td>{{MLOperandDataType/"uint4"}}, {{MLOperandDataType/"uint8"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int32"}}</td>
3849-
<td>0 to {{input}}'s [=MLOperand/rank=]</td>
3852+
<td>{{MLOperandDataType/"uint8"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int32"}}</td>
3853+
<td>[=/same rank as|same as=] {{input}}</td>
38503854
</tr>
38513855
<tr>
38523856
<td>*output*</td>
@@ -4284,7 +4288,7 @@ partial dictionary MLOpSupportLimits {
42844288
<tr>
42854289
<td>{{input}}</td>
42864290
<td>[=/any data type|any=]</td>
4287-
<td>&gt; 1</td>
4291+
<td>1 to [=/any rank|N=]</td>
42884292
</tr>
42894293
<tr>
42904294
<td>{{indices}}</td>
@@ -4327,7 +4331,7 @@ partial dictionary MLOpSupportLimits {
43274331
</div>
43284332

43294333
### gatherND ### {#api-mlgraphbuilder-gathernd}
4330-
Gather values of the input tensor along an axis according to the indices.
4334+
Gather slices of the input tensor according to the indices.
43314335

43324336
<script type=idl>
43334337
partial interface MLGraphBuilder {
@@ -4362,12 +4366,12 @@ partial dictionary MLOpSupportLimits {
43624366
<tr>
43634367
<td>{{input}}</td>
43644368
<td>[=/any data type|any=]</td>
4365-
<td>&gt; 1</td>
4369+
<td>1 to [=/any rank|N=]</td>
43664370
</tr>
43674371
<tr>
43684372
<td>{{indices}}</td>
43694373
<td>{{MLOperandDataType/"int32"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int64"}}</td>
4370-
<td>&gt; 1</td>
4374+
<td>1 to [=/any rank|N=]</td>
43714375
</tr>
43724376
<tr>
43734377
<td>*output*</td>
@@ -7944,6 +7948,8 @@ partial dictionary MLOpSupportLimits {
79447948
1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
79457949
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
79467950
1. If |input|'s [=MLOperand/dataType=] is not one of its [=/allowed data types=] (according to [this table](#constraints-reverse)), then [=exception/throw=] a {{TypeError}}.
7951+
1. If |axes| is not given, let |axes| be [=the range=] 0 to |inputRank|, exclusive.
7952+
1. Otherwise, if |axes| contains duplicate values, or if any of its elements is not in [=the range=] 0 to |inputRank|, exclusive, then return failure.
79477953
1. *Make graph connections:*
79487954
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
79497955
1. Let |operator| be an [=operator=] for the "reverse" operation and |options|.
@@ -7954,7 +7960,7 @@ partial dictionary MLOpSupportLimits {
79547960
</details>
79557961

79567962
### scatterElements ### {#api-mlgraphbuilder-scatterelements}
7957-
Scatter values from the updates tensor along an axis according to the indices in place of the input tensor.
7963+
Scatter values from the updates tensor atop the input tensor the along an axis according to the indices.
79587964

79597965
<script type=idl>
79607966
dictionary MLScatterOptions : MLOperatorOptions {
@@ -8009,7 +8015,7 @@ partial dictionary MLOpSupportLimits {
80098015
<tr>
80108016
<td>{{input}}</td>
80118017
<td>[=/any data type|any=]</td>
8012-
<td>&gt; 1</td>
8018+
<td>1 to [=/any rank|N=]</td>
80138019
</tr>
80148020
<tr>
80158021
<td>{{indices}}</td>
@@ -8070,7 +8076,7 @@ partial dictionary MLOpSupportLimits {
80708076

80718077

80728078
### scatterND ### {#api-mlgraphbuilder-scatternd}
8073-
Scatter values of the input tensor along an axis according to the indices.
8079+
Scatter slices of values from the update tensor atop the input tensor according to the indices.
80748080

80758081
<script type=idl>
80768082
dictionary MLScatterOptions : MLOperatorOptions {
@@ -8123,12 +8129,12 @@ partial dictionary MLOpSupportLimits {
81238129
<tr>
81248130
<td>{{input}}</td>
81258131
<td>[=/any data type|any=]</td>
8126-
<td>&gt; 1</td>
8132+
<td>1 to [=/any rank|N=]</td>
81278133
</tr>
81288134
<tr>
81298135
<td>{{indices}}</td>
81308136
<td>{{MLOperandDataType/"int32"}}, {{MLOperandDataType/"uint32"}}, {{MLOperandDataType/"int64"}}</td>
8131-
<td>&gt; 1</td>
8137+
<td>1 to [=/any rank|N=]</td>
81328138
</tr>
81338139
<tr>
81348140
<td>{{updates}}</td>
@@ -8138,7 +8144,7 @@ partial dictionary MLOpSupportLimits {
81388144
<tr>
81398145
<td>*output*</td>
81408146
<td>[=/same type as|same as=] {{input}}</td>
8141-
<td>&gt; 1</td>
8147+
<td>1 to [=/any rank|N=]</td>
81428148
</tr>
81438149
</table>
81448150

@@ -9542,8 +9548,6 @@ Operations present in other neural network inference APIs can often be emulated
95429548

95439549
<p class="note">{{Float16Array}} is at <a href="https://tc39.es/process-document/">ECMA Stage 3</a> signaling its design is finished. Implementers wanting to enable this type ahead native implementations can emulate the type by passing raw bits via {{Uint16Array}}. <a href="https://github.com/webmachinelearning/webnn/issues/373">[Issue webnn#373]</a></p>
95449550

9545-
<p class="note">There is no Uint4Array/Int4Array class. Nybbles are stored in byte arrays of {{Uint8Array}} with the lower nybble in the lower bits, meaning tensor element 0 would be found in byte 0 bits 0-3, and tensor element 1 in byte 0 bits 4-7 (and so on, with tensor element 5 in byte 2 bits 4-7). Odd tensor element counts are rounded up to whole bytes, and last nybble is ignored, meaning a 5 element tensor uses 3 bytes.</a></p>
9546-
95479551
<h2 id="acknowledgements">Acknowledgements</h2>
95489552

95499553
This specification follows the concepts of the Android Neural Networks API C
@@ -10053,6 +10057,12 @@ Thanks to Feng Dai for his continuous contributions that keep web-platform-tests
1005310057
"Thomas Scialom"
1005410058
],
1005510059
"date": "July 2023"
10060+
},
10061+
"Prefix-Sum": {
10062+
"href": "https://en.wikipedia.org/wiki/Prefix_sum",
10063+
"title": "Prefix Sum",
10064+
"authors": ["The Wikipedia community"],
10065+
"date": "January 2025"
1005610066
}
1005710067
}
1005810068
</pre>

0 commit comments

Comments
 (0)