Skip to content

Commit

Permalink
Move axes vs. rank validation into helper algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
inexorabletash committed May 13, 2024
1 parent 366e446 commit 057019c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,6 @@ partial interface MLGraphBuilder {
</summary>
1. [=Assert=]: |op| is one of "argMin", "argMax".
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLArgMinMaxOptions/axes}} [=map/exists=], if any of its elements is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
1. Let |outputShape| be the result of [=MLGraphBuilder/calculating reduction output sizes=] given |input|'s [=MLOperand/shape=], |options|.{{MLArgMinMaxOptions/axes}} (if it [=map/exists=]), and |options|.{{MLArgMinMaxOptions/keepDimensions}}. If that returns failure, then [=exception/throw=] a {{TypeError}}.
1. Let |desc| be a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to {{MLOperandDataType/"int64"}}.
Expand Down Expand Up @@ -4842,7 +4841,7 @@ partial interface MLGraphBuilder {
</summary>
1. Let |inputRank| be |inputShape|'s [=list/size=].
1. If |axes| is not given, let |axes| be [=the range=] 0 to |inputRank|, exclusive.
1. Otherwise, if |axes| contains duplicate values, then return failure.
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.
1. If |keepDimensions| is true, then:
1. Let |outputShape| be a [=list/clone=] of |inputShape|.
1. [=list/For each=] |axis| of |axes|:
Expand All @@ -4861,7 +4860,6 @@ partial interface MLGraphBuilder {
1. [=Assert=]: |op| is one of "reduceL1", "reduceL2", "reduceLogSum", "reduceLogSumExp", "reduceMax", "reduceMean", "reduceMin", "reduceProduct", "reduceSum", "reduceSumSquare".
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
1. If |allowedDataTypes| is given and it does not [=list/contain=] |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLReduceOptions/axes}} [=map/exists=], if any of its elements is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
1. Let |outputShape| be the result of [=MLGraphBuilder/calculating reduction output sizes=] given |input|'s [=MLOperand/shape=], |options|.{{MLReduceOptions/axes}} (if it [=map/exists=]), and |options|.{{MLReduceOptions/keepDimensions}}. If that returns failure, then [=exception/throw=] a {{TypeError}}.
1. Let |desc| be a new {{MLOperandDescriptor}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |input|'s [=MLOperand/dataType=].
Expand Down

0 comments on commit 057019c

Please sign in to comment.