Skip to content

Commit 8b8d2aa

Browse files
committed
Add gatherND and scatterND algorithm steps
1 parent b1b82c1 commit 8b8d2aa

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

index.bs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,7 +4515,28 @@ partial dictionary MLOpSupportLimits {
45154515
<summary>
45164516
The <dfn method for=MLGraphBuilder>gatherNd(|input|, |indices|, |options|)</dfn> method steps are:
45174517
</summary>
4518-
TODO:
4518+
1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
4519+
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input| and |indices| returns false, then [=exception/throw=] a {{TypeError}}.
4520+
1. If |input|'s or |indices|'s [=MLOperand/dataType=]'s are not one of their [=/allowed data types=] (according to [this table](#constraints-gather)), then [=exception/throw=] a {{TypeError}}.
4521+
1. Let |shapeInput| be |input|'s [=MLOperand/shape=] and |rankInput| be |input|'s [=MLOperand/rank=].
4522+
1. Let |shapeIndices| be |indices|'s [=MLOperand/shape=] and |rankIndices| be |indices|'s [=MLOperand/rank=].
4523+
1. If |rankInput| or |rankIndices| is less than 1, then [=exception/throw=] a {{TypeError}}.
4524+
1. Let |indexableSize| be |rankIndices| - 1.
4525+
1. Let |coordinateSize| be |shapeIndices|[|indexableSize|].
4526+
1. If |coordinateSize| is greater than |inputRank|, then [=exception/throw=] a {{TypeError}}.
4527+
1. Let |shapeOutput| be an empty list.
4528+
1. [=list/For each=] |index| in [=the range=] 0 to |indexableSize|, exclusive:
4529+
1. [=list/Append=] |shapeIndices|[|index|] to |shapeOutput|.
4530+
1. [=list/For each=] |index| in [=the range=] |coordinateSize| to |rankInput|, exclusive:
4531+
1. [=list/Append=] |shapeInput|[|index|] to |shapeOutput|.
4532+
1. Let |outputDesc| be the result of [=creating an MLOperandDescriptor=] given |input|'s [=MLOperand/dataType=] and |shapeOutput|.
4533+
1. *Make graph connections:*
4534+
1. Let |output| be the result of [=creating an MLOperand=] given |outputDesc|.
4535+
1. Let |operator| be an [=operator=] for the "gatherNd" operation, given |input|, |indices|, and |options|.
4536+
1. Set |output|.{{MLOperand/[[operator]]}} to |operator|.
4537+
1. Set |operator|'s [=operator/inputs=] to |input| and |indices|.
4538+
1. Set |operator|'s [=operator/output=] to |output|.
4539+
1. Return |output|.
45194540
</details>
45204541

45214542
<div class="example">
@@ -7676,7 +7697,7 @@ partial dictionary MLOpSupportLimits {
76767697
1. Otherwise:
76777698
1. Let |outputShape| be an empty [=/list=].
76787699
1. [=list/For each=] |index| in [=the range=] 0 to |inputRank|, exclusive:
7679-
1. If |axes| does not [=list/contain=] |index|, then [=list/append=] |inputShape|[|index|].
7700+
1. If |axes| does not [=list/contain=] |index|, then [=list/append=] |inputShape|[|index|] to |outputShape|.
76807701
1. Return |outputShape|.
76817702
</details>
76827703

@@ -8513,7 +8534,31 @@ partial dictionary MLOpSupportLimits {
85138534
<summary>
85148535
The <dfn method for=MLGraphBuilder>scatterNd(|input|, |indices|, |updates|, |options|)</dfn> method steps are:
85158536
</summary>
8516-
TODO:
8537+
1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
8538+
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input|, |indices|, and |updates| returns false, then [=exception/throw=] a {{TypeError}}.
8539+
1. If |input|'s or |indices|'s [=MLOperand/dataType=]'s are not one of their [=/allowed data types=] (according to [this table](#constraints-gather)), then [=exception/throw=] a {{TypeError}}.
8540+
1. If |udpates|'s [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
8541+
1. Let |shapeInput| be |input|'s [=MLOperand/shape=] and |rankInput| be |input|'s [=MLOperand/rank=].
8542+
1. Let |shapeIndices| be |indices|'s [=MLOperand/shape=] and |rankIndices| be |indices|'s [=MLOperand/rank=].
8543+
1. If |rankInput| or |rankIndices| is less than 1, then [=exception/throw=] a {{TypeError}}.
8544+
1. Let |indexableSize| be |rankIndices| - 1.
8545+
1. Let |coordinateSize| be |shapeIndices|[|indexableSize|].
8546+
1. If |coordinateSize| is greater than |inputRank|, then [=exception/throw=] a {{TypeError}}.
8547+
1. Let |shapeUpdates| be an empty list.
8548+
1. [=list/For each=] |index| in [=the range=] 0 to |indexableSize|, exclusive:
8549+
1. [=list/Append=] |shapeIndices|[|index|] to |shapeUpdates|.
8550+
1. [=list/For each=] |index| in [=the range=] |coordinateSize| to |rankInput|, exclusive:
8551+
1. [=list/Append=] |shapeInput|[|index|] to |shapeUpdates|.
8552+
1. Let |updates|'s [=MLOperand/shape=] is not equal to |shapeUpdates|, then [=exception/throw=] a {{TypeError}}.
8553+
1. Let |outputShape| be a copy of |input|'s [=MLOperand/shape=].
8554+
1. Let |outputDesc| be the result of [=creating an MLOperandDescriptor=] given |input|'s [=MLOperand/dataType=] and |shapeOutput|.
8555+
1. *Make graph connections:*
8556+
1. Let |output| be the result of [=creating an MLOperand=] given |outputDesc|.
8557+
1. Let |operator| be an [=operator=] for the "scatterNd" operation, given |input|, |indices|, |updates|, and |options|.
8558+
1. Set |output|.{{MLOperand/[[operator]]}} to |operator|.
8559+
1. Set |operator|'s [=operator/inputs=] to |input|, |indices|, and |updates|.
8560+
1. Set |operator|'s [=operator/output=] to |output|.
8561+
1. Return |output|.
85178562
</details>
85188563

85198564
<div class="example">

0 commit comments

Comments
 (0)