From 295cd0b837da27f15780106049dba0ebcf44d4be Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 2 May 2024 12:16:21 -0700 Subject: [PATCH] Varioius fixes - 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. --- index.bs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/index.bs b/index.bs index b4b2eef0..1db6c492 100644 --- a/index.bs +++ b/index.bs @@ -3056,11 +3056,11 @@ partial interface MLGraphBuilder { {{a}} {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}} - [=/any rank|N=] + 2 {{b}} [=/same as=] {{a}} - [=/any rank|N=] + 2 {{MLGemmOptions/c}} [=/same as=] {{a}} @@ -3073,9 +3073,8 @@ partial interface MLGraphBuilder { The gemm(|a|, |b|, |options|) method steps are: 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|. @@ -3238,7 +3237,7 @@ partial interface MLGraphBuilder { 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]. @@ -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]. @@ -4836,8 +4835,7 @@ partial interface MLGraphBuilder { The matmul(|a|, |b|) method steps are: 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. @@ -5219,7 +5217,7 @@ partial interface MLGraphBuilder { The prelu(|input|, |slope|) method steps are: 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=]. @@ -6242,7 +6240,7 @@ partial interface MLGraphBuilder { 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:* @@ -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. + + + + + +
input operand + [=/allowed data types=] + [=/allowed ranks=] +
{{input}} + [=/any data type|any=] + 2 or greater +
+ +
The triangular(|input|, |options|) method steps are: - 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|. @@ -6408,8 +6420,7 @@ partial interface MLGraphBuilder { The where(|condition|, |input|, |other|) method steps are: - 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=].