Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- gemm(): Fix ranks in table, align phrasing.
- gru(): Align phrasing.
- lstm(): Don't inline rank of 3, reference table.
- matmul(): Align phrasing.
- prelu(): Fix punctation.
- triangular(): Add table, use for rank validation.
- where(): Align phrasing.
  • Loading branch information
inexorabletash committed May 2, 2024
1 parent 12127a0 commit 4c13bf8
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3056,11 +3056,11 @@ partial interface MLGraphBuilder {
<tr>
<td>{{a}}
<td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}
<td>[=/any rank|N=]
<td>2
<tr>
<td>{{b}}
<td>[=/same as=] {{a}}
<td>[=/any rank|N=]
<td>2
<tr>
<td>{{MLGemmOptions/c}}
<td>[=/same as=] {{a}}
Expand All @@ -3073,9 +3073,8 @@ partial interface MLGraphBuilder {
The <dfn method for=MLGraphBuilder>gemm(|a|, |b|, |options|)</dfn> method steps are:
</summary>
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |a| and |b| returns false, then [=exception/throw=] a {{TypeError}}.
1. If |a|'s [=MLOperand/dataType=] is one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |b|'s [=MLOperand/dataType=] is one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |a|'s [=MLOperand/rank=] is not 2 or |b|'s [=MLOperand/rank=] is not 2, then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of any of |a| or |b| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/rank=] of any of |a| or |b| is not its [=allowed rank=], then [=exception/throw=] a {{TypeError}}.
1. Let |shapeA| be a [=list/clone=] of |a|'s [=MLOperand/shape=].
1. Let |shapeB| be a [=list/clone=] of |b|'s [=MLOperand/shape=].
1. If |options|.{{MLGemmOptions/aTranspose}} is true, then reverse the order of the items in |shapeA|.
Expand Down Expand Up @@ -3238,7 +3237,7 @@ partial interface MLGraphBuilder {
</summary>
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input|, |weight|, |recurrentWeight|, |options|.{{MLGruOptions/bias}} (if it [=map/exists=]), |options|.{{MLGruOptions/recurrentBias}} (if it [=map/exists=]), and |options|.{{MLGruOptions/initialHiddenState}} (if it [=map/exists=]) returns false, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLGruOptions/activations}} [=map/exists=], and [=MLGraphBuilder/validating activation=] with [=this=] and any [=list/item=] in it returns false, then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of either |input|, |weight| or |recurrentWeight| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of any of |input|, |weight| or |recurrentWeight| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/rank=] of any of |input|, |weight| or |recurrentWeight| is not its [=allowed rank=], then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/shape=][0] is not equal to |steps|, then [=exception/throw=] a {{TypeError}}.
1. Let |batchSize| be |input|'s [=MLOperand/shape=][1].
Expand Down Expand Up @@ -4347,7 +4346,7 @@ partial interface MLGraphBuilder {
1. If |options|.{{MLLstmOptions/activations}} [=map/exists=], and [=MLGraphBuilder/validating activation=] with [=this=] and any [=list/item=] in it returns false, then [=exception/throw=] a {{TypeError}}.
1. Let |numDirections| be 2 if |options|.{{MLLstmOptions/direction}} is {{MLRecurrentNetworkDirection/"both"}}, or 1 otherwise.
1. If the [=MLOperand/dataType=] of any of |input|, |weight| or |recurrentWeight| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/rank=] of any of |input|, |weight| or |recurrentWeight| is not 3, then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/rank=] of any of |input|, |weight| or |recurrentWeight| is not its [=allowed rank=], then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/shape=][0] is not equal to |steps|, then [=exception/throw=] a {{TypeError}}.
1. Let |batchSize| be |input|'s [=MLOperand/shape=][1].
1. Let |inputSize| be |input|'s [=MLOperand/shape=][2].
Expand Down Expand Up @@ -4836,8 +4835,7 @@ partial interface MLGraphBuilder {
The <dfn method for=MLGraphBuilder>matmul(|a|, |b|)</dfn> method steps are:
</summary>
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |a| and |b| returns false, then [=exception/throw=] a {{TypeError}}.
1. If |a|'s [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.,
1. If |b|'s [=MLOperand/dataType=] is not equal to |a|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of any of |a| or |b| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. Let |desc| be a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to the result of [=MLGraphBuilder/calculating matmul output sizes=] given |a| and |b|.
1. If that throws an error, re-[=exception/throw=] the error.
Expand Down Expand Up @@ -5219,7 +5217,7 @@ partial interface MLGraphBuilder {
The <dfn method for=MLGraphBuilder>prelu(|input|, |slope|)</dfn> method steps are:
</summary>
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input| and |slope| returns false, then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of any of |input| or |slope| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.,
1. If the [=MLOperand/dataType=] of any of |input| or |slope| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |input|'s [=MLOperand/dataType=].
1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the result of [=unidirectionally broadcasting the shapes=] |slope|'s [=MLOperand/shape=] and |input|'s [=MLOperand/shape=].
Expand Down Expand Up @@ -6242,7 +6240,7 @@ partial interface MLGraphBuilder {
</summary>
1. If |options|.{{MLTransposeOptions/permutation}} does not [=map/exist=], let |options|.{{MLTransposeOptions/permutation}} be the reversed sequence of all indices for |input|'s [=MLOperand/shape=].
1. Otherwise if |options|.{{MLTransposeOptions/permutation}} [=map/exists=]:
1. If its [=MLOperand/rank=] is not equal to |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
1. If its [=list/size=] is not equal to |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
1. If its values are not in [=the range=] 0 to |input|'s [=MLOperand/rank=] exclusive, then [=exception/throw=] a {{TypeError}}.
1. If it contains duplicate values, then [=exception/throw=] a {{TypeError}}.
1. *Make graph connections:*
Expand Down Expand Up @@ -6286,11 +6284,25 @@ partial interface MLGraphBuilder {
**Returns:** an {{MLOperand}}. The output tensor representing a triangular matrix, or batch of matrices which is the same shape as the input.
</div>

<table class='data' link-for="MLGraphBuilder/triangular(input, options)">
<thead class=stickyheader>
<tr>
<th>input operand
<th>[=/allowed data types=]
<th>[=/allowed ranks=]
</thead>
<tr>
<td>{{input}}
<td>[=/any data type|any=]
<td>2 or greater
</table>


<details open algorithm>
<summary>
The <dfn method for=MLGraphBuilder>triangular(|input|, |options|)</dfn> method steps are:
</summary>
1. If |input|'s [=MLOperand/rank=] is less than 2, then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/rank=] is not one of its [=allowed ranks=], then [=exception/throw=] a {{TypeError}}.
1. *Make graph connections:*
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
1. Let |operator| be an [=operator=] for the triangular operation, given |options|.
Expand Down Expand Up @@ -6408,8 +6420,7 @@ partial interface MLGraphBuilder {
<summary>
The <dfn method for=MLGraphBuilder>where(|condition|, |input|, |other|)</dfn> method steps are:
</summary>
1. If |condition|'s [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/dataType=] is not equal to |other|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If the [=MLOperand/dataType=] of any of |condition|, |input|, or |other| is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |input|'s [=MLOperand/dataType=].
1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the result of [=bidirectionally broadcasting the shapes=] |input|'s [=MLOperand/shape=] and |other|'s [=MLOperand/shape=].
Expand Down

0 comments on commit 4c13bf8

Please sign in to comment.