Skip to content

Commit fccaccb

Browse files
authored
Merge pull request #819 from inexorabletash/items-and-fix
Fix returning failure from methods, and use "item" for lists
2 parents d17fe35 + 3abc98f commit fccaccb

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

index.bs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ Issue(391): Should 0-size dimensions be supported?
14021402
<summary>
14031403
To <dfn for="MLOperandDescriptor">check dimensions</dfn> given {{MLOperandDescriptor}} |descriptor|, run the following steps:
14041404
</summary>
1405-
1. If any element of |descriptor|.{{MLOperandDescriptor/shape}} is not a [=valid dimension=], return false.
1405+
1. If any [=list/item=] of |descriptor|.{{MLOperandDescriptor/shape}} is not a [=valid dimension=], return false.
14061406
1. If |descriptor|.{{MLOperandDescriptor/shape}}'s [=list/size=] is too large to be supported by the implementation, return false.
14071407

14081408
Issue(456): The maximum number of operand dimensions is not defined, but native ML APIs usually have a maximum supported size.
@@ -2627,10 +2627,10 @@ partial dictionary MLOpSupportLimits {
26272627
1. Otherwise, if |options|.{{MLConv2dOptions/padding}}'s [=list/size=] is not 4, then [=exception/throw=] a {{TypeError}}.
26282628
1. If |options|.{{MLConv2dOptions/strides}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
26292629
1. Otherwise, if |options|.{{MLConv2dOptions/strides}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
2630-
1. If any element in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
2630+
1. If any [=list/item=] in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
26312631
1. If |options|.{{MLConv2dOptions/dilations}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
26322632
1. Otherwise, if |options|.{{MLConv2dOptions/dilations}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
2633-
1. If any element in |options|.{{MLConv2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
2633+
1. If any [=list/item=] in |options|.{{MLConv2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
26342634
1. If |options|.{{MLConv2dOptions/groups}} is 0, then [=exception/throw=] a {{TypeError}}.
26352635
1. *Calculate the output shape:*
26362636
1. Let |inputShape| be |input|'s [=MLOperand/shape=].
@@ -2844,10 +2844,10 @@ partial dictionary MLOpSupportLimits {
28442844
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/padding}}'s [=list/size=] is not 4, then [=exception/throw=] a {{TypeError}}.
28452845
1. If |options|.{{MLConvTranspose2dOptions/strides}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
28462846
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/strides}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
2847-
1. If any element in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
2847+
1. If any [=list/item=] in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
28482848
1. If |options|.{{MLConvTranspose2dOptions/dilations}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
28492849
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/dilations}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
2850-
1. If any element in |options|.{{MLConvTranspose2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
2850+
1. If any [=list/item=] in |options|.{{MLConvTranspose2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
28512851
1. If |options|.{{MLConvTranspose2dOptions/outputPadding}} does not [=map/exist=], set it to the [=/list=] « 0, 0 ».
28522852
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/outputPadding}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
28532853
1. If |options|.{{MLConvTranspose2dOptions/outputSizes}} [=map/exists=]:
@@ -5152,7 +5152,7 @@ partial dictionary MLOpSupportLimits {
51525152
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input|, |options|.{{MLLayerNormalizationOptions/scale}} (if it [=map/exists=]), and |options|.{{MLLayerNormalizationOptions/bias}} (if it [=map/exists=]) returns false, then [=exception/throw=] a {{TypeError}}.
51535153
1. If |input|'s [=MLOperand/dataType=] is not one of its [=/allowed data types=] (according to [this table](#constraints-layerNormalization)), then [=exception/throw=] a {{TypeError}}.
51545154
1. If |options|.{{MLLayerNormalizationOptions/axes}} does not [=map/exist=], then set |options|.{{MLLayerNormalizationOptions/axes}} to a new [=/list=], either [=the range=] from 1 to |input|'s [=MLOperand/rank=], exclusive, if |input|'s [=MLOperand/rank=] is greater than 1, or an empty [=/list=] otherwise.
5155-
1. Otherwise, if |options|.{{MLLayerNormalizationOptions/axes}} contains duplicate values, or if any of its elements is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then return failure.
5155+
1. Otherwise, if |options|.{{MLLayerNormalizationOptions/axes}} contains duplicate values, or if any of its [=list/items=] is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
51565156
1. Set |options|.{{MLLayerNormalizationOptions/epsilon}} to the result of [=casting=] |options|.{{MLLayerNormalizationOptions/epsilon}} to |input|'s [=MLOperand/dataType=].
51575157
1. If |options|.{{MLLayerNormalizationOptions/scale}} [=map/exists=]:
51585158
1. If its [=MLOperand/dataType=] is not one of its [=/allowed data types=] (according to [this table](#constraints-layerNormalization)), then [=exception/throw=] a {{TypeError}}.
@@ -6554,7 +6554,7 @@ partial dictionary MLOpSupportLimits {
65546554
1. If any value in |options|.{{MLPool2dOptions/strides}} is not greater than 0, then [=exception/throw=] a {{TypeError}}.
65556555
1. If |options|.{{MLPool2dOptions/outputSizes}} [=map/exists=]:
65566556
1. If its [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
6557-
1. If its elements are not smaller than the elements at the same dimension (index) for |options|.{{MLPool2dOptions/strides}}, then [=exception/throw=] a {{TypeError}}.
6557+
1. If its [=list/items=] are not smaller than the [=list/items=] at the same dimension (index) for |options|.{{MLPool2dOptions/strides}}, then [=exception/throw=] a {{TypeError}}.
65586558
1. If |options|.{{MLPool2dOptions/dilations}} does not [=map/exist=], set |options|.{{MLPool2dOptions/dilations}} to the [=/list=] « 1, 1 ».
65596559
1. If |options|.{{MLPool2dOptions/dilations}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
65606560
1. If any value in |options|.{{MLPool2dOptions/dilations}} is not greater than 0, then [=exception/throw=] a {{TypeError}}.
@@ -6864,7 +6864,7 @@ partial dictionary MLOpSupportLimits {
68646864
</summary>
68656865
1. Let |inputRank| be |inputShape|'s [=list/size=].
68666866
1. If |axes| is not given, let |axes| be [=the range=] 0 to |inputRank|, exclusive.
6867-
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.
6867+
1. Otherwise, if |axes| contains duplicate values, or if any of its [=list/items=] is not in [=the range=] 0 to |inputRank|, exclusive, then return failure.
68686868
1. If |keepDimensions| is true, then:
68696869
1. Let |outputShape| be a [=list/clone=] of |inputShape|.
68706870
1. [=list/For each=] |axis| of |axes|:
@@ -7206,14 +7206,14 @@ partial dictionary MLOpSupportLimits {
72067206
1. Otherwise, if any of its values is not greater than 0, or if its [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
72077207
1. If |options|.{{MLResample2dOptions/sizes}} [=map/exists=], and if its size is not 2, or if any of its values is not greater than 0, then [=exception/throw=] a {{TypeError}}.
72087208
1. If |options|.{{MLResample2dOptions/axes}} does not [=map/exists=], set it to the [=/list=] « 2, 3 ».
7209-
1. Otherwise, if |options|.{{MLResample2dOptions/axes}} contains duplicate values, or if any of its elements is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
7209+
1. Otherwise, if |options|.{{MLResample2dOptions/axes}} contains duplicate values, or if any of its [=list/items=] is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
72107210
1. *Calculate the output shape:*
72117211
1. Let |inputDescriptor| be |input|.{{MLOperand/[[descriptor]]}}.
72127212
1. Let |outputShape| be a [=list/clone=] of |inputDescriptor|.{{MLOperandDescriptor/shape}}.
72137213
1. [=list/For each=] |index| in [=the range=] 0 to |options|.{{MLResample2dOptions/axes}}'s [=list/size=], exclusive:
72147214
1. If |options|.{{MLResample2dOptions/sizes}} [=map/exists=], then let |size| be |options|.{{MLResample2dOptions/sizes}}[|index|].
72157215
1. Otherwise, let |size| be floor(|input|'s [=MLOperand/shape=][|options|.{{MLResample2dOptions/axes}}[|index|]] * |options|.{{MLResample2dOptions/scales}}[|index|]).
7216-
1. If |size| is not a [=valid dimension=], then return failure.
7216+
1. If |size| is not a [=valid dimension=], then [=exception/throw=] a {{TypeError}}.
72177217
1. Set |outputShape|[|options|.{{MLResample2dOptions/axes}}[|index|]] to |size|.
72187218
1. Let |desc| be the result of [=creating an MLOperandDescriptor=] given |inputDescriptor|.{{MLOperandDescriptor/dataType}} and |outputShape|.
72197219
1. *Make graph connections:*
@@ -7314,7 +7314,7 @@ partial dictionary MLOpSupportLimits {
73147314
1. Let |outputShape| be an empty array of {{unsigned long}}.
73157315
1. If |newShape|'s [=list/size=] is 0, set |outputShape| to an empty [=/list=] for a scalar.
73167316
1. If any [=list/item=] in |newShape| is not a [=valid dimension=], then [=exception/throw=] a {{TypeError}}.
7317-
1. Let |inputElementCount| be the product of all elements in |input|'s [=MLOperand/shape=]. Empty dimensions yield an |inputElementCount| of 1.
7317+
1. Let |inputElementCount| be the product of all [=list/items=] in |input|'s [=MLOperand/shape=]. Empty dimensions yield an |inputElementCount| of 1.
73187318
1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a {{TypeError}}.
73197319
1. Let |desc| be a copy of |input|.{{MLOperand/[[descriptor]]}}.
73207320
1. Set |desc|.{{MLOperandDescriptor/shape}} to |newShape|.
@@ -7819,11 +7819,11 @@ partial dictionary MLOpSupportLimits {
78197819
1. If |input|'s [=MLOperand/shape=][|axis|] % |splits| is not 0, then [=exception/throw=] a {{TypeError}}.
78207820
1. Otherwise, let |splitCount| be |splits|.
78217821
1. If |splits| is a [=sequence=]<{{unsigned long}}>:
7822-
1. If any of its elements is equal to 0, then [=exception/throw=] a {{TypeError}}.
7822+
1. If any of its [=list/items=] is equal to 0, then [=exception/throw=] a {{TypeError}}.
78237823

78247824
Issue(391): If 0-size dimensions are allowed, revise the above step.
78257825

7826-
1. If the sum of its elements is not equal to |input|'s [=MLOperand/shape=][|axis|], then [=exception/throw=] a {{TypeError}}.
7826+
1. If the sum of its [=list/items=] is not equal to |input|'s [=MLOperand/shape=][|axis|], then [=exception/throw=] a {{TypeError}}.
78277827
1. Otherwise, let |splitCount| be |splits|'s [=list/size=].
78287828
1. *Make graph connections:*
78297829
1. Let |operator| be an [=operator=] for the "split" operation, given |splits| and |options|.

0 commit comments

Comments
 (0)