Skip to content

Commit

Permalink
Bruce Dai Feng's feedback on MLOperandDescriptor/dataType
Browse files Browse the repository at this point in the history
  • Loading branch information
fdwr committed Sep 22, 2023
1 parent 001bf91 commit 55d8a14
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ dictionary MLOperandDescriptor {
1. Let |elementLength| be 1.
1. [=map/For each=] |dimension| of |desc|.{{MLOperandDescriptor/dimensions}}:
1. Set |elementLength| to |elementLength| × |dimension|.
1. Let |elementSize| be the [=element size=] of one of the {{ArrayBufferView}} types that matches |desc|.{{MLOperandDescriptor/type}} according to [this table](#appendices-mloperanddatatype-arraybufferview-compatibility).
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).
1. Return |elementLength| × |elementSize|.
</div>
</details>
Expand Down Expand Up @@ -1011,7 +1011,7 @@ The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, inte
1. [=Assert=]: the type of |operand|.{{MLOperand/[[builder]]}} is {{MLGraphBuilder}}.
1. If |builder| is not equal to |operand|.{{MLOperand/[[builder]]}}, return false.
1. Let |desc| be |operand|.{{MLOperand/[[descriptor]]}}.
1. If |desc|.{{MLOperandDescriptor/dimensions}} [=map/exists=] and invoking <a>check dimensions</a> given |desc|.{{MLOperandDescriptor/dimensions}} and |desc|.{{MLOperandDescriptor/type}} returns false, then return false.
1. If |desc|.{{MLOperandDescriptor/dimensions}} [=map/exists=] and invoking <a>check dimensions</a> given |desc|.{{MLOperandDescriptor/dimensions}} and |desc|.{{MLOperandDescriptor/dataType}} returns false, then return false.
1. Return true.
</div>
</details>
Expand Down Expand Up @@ -1198,7 +1198,7 @@ partial interface MLContext {
</summary>
<div class=algorithm-steps>
1. If |bufferView| is not an {{MLBufferView}}, return false.
1. If |bufferView|'s [=element type=] does not match to |descriptor|.{{MLOperandDescriptor/type}} according to [this table](#appendices-mloperanddatatype-arraybufferview-compatibility), return false.
1. If |bufferView|'s [=element type=] does not match to |descriptor|.{{MLOperandDescriptor/dataType}} according to [this table](#appendices-mloperanddatatype-arraybufferview-compatibility), return false.
1. If |bufferView|.\[[ByteLength]] is not equal to the [=byte length=] of |descriptor|, return false.
</div>
</details>
Expand Down Expand Up @@ -1613,7 +1613,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
1. [=Assert=]: the type of |descriptor| is {{MLOperandDescriptor}}.
1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input.
1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]:
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |operand| be the result of <a>creating an MLOperand</a> given [=this=] and |descriptor|.
Expand Down Expand Up @@ -1703,7 +1703,7 @@ Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods.
</div>
1. [=Assert=]: the type of |descriptor| is {{MLOperandDescriptor}}.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If <a>validating buffer with descriptor</a> given |bufferView| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |operand| be the result of <a>creating an MLOperand</a> given [=this=] and |descriptor|.
Expand Down Expand Up @@ -1734,7 +1734,7 @@ Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods.
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
</div>
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
1. Set |descriptor|.{{MLOperandDescriptor/type}} to |type|.
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |type|.
1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to `undefined`.
<div class="note">
In the case of a scalar constant, |descriptor|.{{MLOperandDescriptor/dimensions}} is ignored.
Expand Down Expand Up @@ -1987,15 +1987,15 @@ partial interface MLGraphBuilder {
1. [=Assert=]: the type of |inputs| is sequence of {{MLOperand}} objects.
1. [=Assert=]: the type of |axis| is `unsigned long`.
1. [=Assert=]: the shape, i.e. {{MLOperandDescriptor/dimensions}} of each operand in |inputs| is the same, except on the dimension given by |axis| on which they are concatenated.
1. [=Assert=]: the {{MLOperandDescriptor/type}} of each operand in |inputs| is the same.
1. [=Assert=]: the {{MLOperandDescriptor/dataType}} of each operand in |inputs| is the same.
1. If any of the following steps fail, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. Let |desc| be |inputs|[0].{{MLOperand/[[descriptor]]}}.
1. If |axis| is greater than or equal to the [=rank=] of |desc|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. Let |desc|.{{MLOperandDescriptor/dimensions}}[|axis|] be 0.
1. [=map/For each=] |index| in [=the range=] 0 to the [=rank=] of |inputs|, exclusive:
1. Let |input| be |inputs|[|index|].
1. If <a>validating MLOperand</a> given |input| and [=this=] returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not equal to |inputs|[0].{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not equal to |inputs|[0].{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. [=map/For each=] |dim| in [=the range=] 0 to the [=rank=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, exclusive:
<div class="note">
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.
Expand Down Expand Up @@ -2146,7 +2146,7 @@ partial interface MLGraphBuilder {
1. Let |filterSize| be the [=list/size=] of |filter|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}.
1. If |inputSize| is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |filterSize| is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not the same as |filter|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a {{TypeError}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not the same as |filter|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConv2dOptions/padding}} does not [=map/exist=], set it to `« 0, 0, 0, 0 »`.
1. Else if the [=list/size=] of |options|.{{MLConv2dOptions/padding}} is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |options|.{{MLConv2dOptions/strides}} does not [=map/exist=], set it to `« 1, 1 »`.
Expand All @@ -2161,13 +2161,13 @@ partial interface MLGraphBuilder {
1. If |options|.{{MLConv2dOptions/bias}} [=map/exists=]:
1. [=Assert=]: the type of |options|.{{MLConv2dOptions/bias}} is {{MLOperand}}.
1. If the [=list/size=] of |options|.{{MLConv2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is not 1, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConv2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not the same as |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConv2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not the same as |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConv2dOptions/activation}} [=map/exists=]:
1. [=Assert=]: the type of |options|.{{MLConv2dOptions/activation}} is {{MLActivation}}.
1. Let |outputShape| be the result of invoking the underlying implementation for calculating output dimensions, given |options|.
1. If |outputShape| is not the same as the shape of |options|.{{MLConv2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |outputShape|.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
Expand Down Expand Up @@ -2322,7 +2322,7 @@ partial interface MLGraphBuilder {
1. Let |filterSize| be the [=list/size=] of |filter|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}.
1. If |inputSize| is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |filterSize| is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not the same as {{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a {{TypeError}}.
1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not the same as {{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConvTranspose2dOptions/padding}} does not [=map/exist=], set it to `« 0, 0, 0, 0 »`.
1. Else if the [=list/size=] of |options|.{{MLConvTranspose2dOptions/padding}} is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |options|.{{MLConvTranspose2dOptions/strides}} does not [=map/exist=], set it to `« 1, 1 »`.
Expand All @@ -2340,13 +2340,13 @@ partial interface MLGraphBuilder {
1. If |options|.{{MLConvTranspose2dOptions/bias}} [=map/exists=]:
1. [=Assert=]: the type of |options|.{{MLConvTranspose2dOptions/bias}} is {{MLOperand}}.
1. If the [=list/size=] of |options|.{{MLConvTranspose2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is not 1, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConvTranspose2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not the same as |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConvTranspose2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not the same as |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLConvTranspose2dOptions/activation}} [=map/exists=]:
1. [=Assert=]: the type of |options|.{{MLConvTranspose2dOptions/activation}} is {{MLActivation}}.
1. Let |outputShape| be the result of invoking the underlying implementation for calculating output dimensions, given |options|.
1. If |outputShape| is not the same as the shape of |options|.{{MLConvTranspose2dOptions/bias}}.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |outputShape|.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
Expand Down Expand Up @@ -2409,9 +2409,9 @@ partial interface MLGraphBuilder {
<div class=algorithm-steps>
1. [=Assert=]: |op| is one of "add", "sub", "mul", "div", "max", "min", "pow".
1. [=Assert=]: the type of |a| and |b| is {{MLOperand}}.
1. If |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}} is not equal to |b|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. If |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}} is not equal to |b|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
1. Set |descriptor|.{{MLOperandDescriptor/type}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. Let |descriptor|.{{MLOperandDescriptor/dimensions}} be the result of running the [=MLGraphBuilder/broadcast-shapes=] steps given |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} and |b|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}.
1. If that [=exception/throws=] an error, re-[=exception/throw=] the error.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
Expand Down Expand Up @@ -2780,7 +2780,7 @@ partial interface MLGraphBuilder {
</div>
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to [|shapeA|[0], |shapeB|[1]].
1. Set |desc|.{{MLOperandDescriptor/type}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Make a request to the underlying platform to:
Expand Down Expand Up @@ -3060,7 +3060,7 @@ partial interface MLGraphBuilder {
1. If |options|.{{MLGruOptions/activations}} [=map/exists=] and its [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to [ |input|.{{MLOperandDescriptor/dimensions}}[0], |hiddenSize| ].
1. Set |desc|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Make a request to the underlying platform to:
Expand Down Expand Up @@ -3764,7 +3764,7 @@ partial interface MLGraphBuilder {
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to [ |numDirections|, |batchSize|, |hiddenSize| ].
1. Set |desc|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. Let |output0| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Let |output1| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to [ |steps|, |numDirections|, |batchSize|, |hiddenSize| ].
Expand Down Expand Up @@ -3945,7 +3945,7 @@ partial interface MLGraphBuilder {
1. [=Assert=]: the type of its elements is {{MLActivation}}.
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to [ |batchSize|, |hiddenSize| ].
1. Set |desc|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output0| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Let |output1| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
Expand Down Expand Up @@ -4133,7 +4133,7 @@ partial interface MLGraphBuilder {
1. Let |desc| a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to the result of invoking the <a>calculate matmul output sizes</a> steps given |a| and |b|.
1. If that throws an error, re-[=exception/throw=] the error.
1. Set |desc|.{{MLOperandDescriptor/type}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |a|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>creating an MLOperand</a> given [=this=] and |desc|.
1. Make a request to the underlying platform to:
Expand Down Expand Up @@ -4479,7 +4479,7 @@ partial interface MLGraphBuilder {
<div class=algorithm-steps>
1. [=Assert=]: the type of |input| and |slope| is {{MLOperand}}.
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
1. Set |descriptor|.{{MLOperandDescriptor/type}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/type}}.
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
1. Let |descriptor|.{{MLOperandDescriptor/dimensions}} be the result of running the [=MLGraphBuilder/broadcast-shapes=] steps given |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} and |slope|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}.
1. If that [=exception/throws=] an error, re-[=exception/throw=] the error.
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
Expand Down

0 comments on commit 55d8a14

Please sign in to comment.