Skip to content

Commit 5027d85

Browse files
committed
Update slice algorithm steps for strides
1 parent 658d493 commit 5027d85

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

index.bs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8838,19 +8838,27 @@ partial dictionary MLOpSupportLimits {
88388838
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
88398839
1. If any of |sizes|'s [=list/items=] are 0, then [=exception/throw=] a {{TypeError}}.
88408840
1. If |starts|'s [=list/size=] and |sizes|'s [=list/size=] are not both equal to |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
8841+
1. Let |strides| be a new [=/list=].
88418842
1. If |options|.{{MLSliceOptions/strides}} [=map/exists=]:
8842-
1. If |options|.{{MLSliceOptions/strides}}'s [=list/size=] is not equal to |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
8843-
1. [=list/For each=] |index| in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive:
8843+
1. Set |strides| to |options|.{{MLSliceOptions/strides}}.
8844+
1. If |strides|'s [=list/size=] is not equal to |input|'s [=MLOperand/rank=], then [=exception/throw=] a {{TypeError}}.
8845+
1. Let |inputShape| be |input|'s [=MLOperand/shape=] and |inputRank| be |input|'s [=MLOperand/rank=].
8846+
1. Let |outputShape| be a new [=/list=].
8847+
1. [=list/For each=] |index| in [=the range=] 0 to |inputRank|, exclusive:
88448848
1. If |sizes|[|index|] is 0, then [=exception/throw=] a {{TypeError}}.
88458849

88468850
Issue(391): If 0-size dimensions are allowed, revise these steps.
88478851

8848-
1. If |starts|[|index|] is greater than or equal to |input|'s [=MLOperand/shape=][|index|], then [=exception/throw=] a {{TypeError}}.
8849-
1. If |starts|[|index|] + |sizes|[|index|] is greater than |input|'s [=MLOperand/shape=][|index|], then [=exception/throw=] a {{TypeError}}.
8850-
1. If |options|.{{MLSliceOptions/strides}} [=map/exists=]:
8851-
1. If |options|.{{MLSliceOptions/strides}}[|index|] is less than 1, then [=exception/throw=] a {{TypeError}}.
8852+
1. If |starts|[|index|] is greater than |inputShape|[|index|], then [=exception/throw=] a {{TypeError}}.
8853+
1. If |starts|[|index|] + |sizes|[|index|] is greater than |inputShape|[|index|], then [=exception/throw=] a {{TypeError}}.
8854+
1. Let |stride| be |strides|[|index|] if it is not empty, or 1 otherwise:
8855+
1. If |stride| is less than 1, then [=exception/throw=] a {{TypeError}}.
8856+
1. Let |outputSizeRoundingExcess| be 1 if |inputShape|[|index|] % |stride| != 0, or 0 otherwise.
8857+
1. Let |outputSize| be |inputShape|[|index|] / |stride| + |outputSizeRoundingExcess|
8858+
1. [=list/Append=] |outputSize| to |outputShape|.
8859+
1. Let |outputDesc| be the result of [=creating an MLOperandDescriptor=] given |input|'s [=MLOperand/dataType=] and |outputShape|.
88528860
1. *Make graph connections:*
8853-
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
8861+
1. Let |output| be the result of [=creating an MLOperand=] given |outputDesc|.
88548862
1. Let |operator| be an [=operator=] for the "slice" operation, given |starts|, |sizes|, and |options|.
88558863
1. Set |output|.{{MLOperand/[[operator]]}} to |operator|.
88568864
1. Set |operator|'s [=operator/input=] to |input|.

0 commit comments

Comments
 (0)