Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add outputDataType to argmin/argmax #730

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ Return the index location of the minimum or maxmium values of all the input valu
<script type=idl>
dictionary MLArgMinMaxOptions {
boolean keepDimensions = false;
MLOperandDataType outputDataType = "int32";
fdwr marked this conversation as resolved.
Show resolved Hide resolved
};

partial interface MLGraphBuilder {
Expand All @@ -1532,6 +1533,10 @@ partial interface MLGraphBuilder {
: <dfn>keepDimensions</dfn>
::
If true, retains reduced dimensions with [=list/size=] 1.

: <dfn>outputDataType</dfn>
::
An {{MLOperandDataType}}. The output data type.
</dl>

<div dfn-for="MLGraphBuilder/argMin(input, axis, options), MLGraphBuilder/argMax(input, axis, options)" dfn-type=argument>
Expand All @@ -1540,7 +1545,7 @@ partial interface MLGraphBuilder {
- <dfn>axis</dfn>: The dimension to reduce. The value must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensor.
- <dfn>options</dfn>: an optional {{MLArgMinMaxOptions}}. The optional parameters of the operation.

**Returns:** an {{MLOperand}}. The N-D tensor of the reduced shape. The values must be of type {{MLOperandDataType/"int64"}} in the range [0, N-1] where N is the size of the input dimension specified by axis.
**Returns:** an {{MLOperand}}. The N-D tensor of the reduced shape. The values must be of type |options|.{{MLArgMinMaxOptions/outputDataType}} in the range [0, N-1] where N is the size of the input dimension specified by axis.
</div>

<details open algorithm>
Expand All @@ -1550,9 +1555,10 @@ partial interface MLGraphBuilder {
1. [=Assert=]: |op| is one of "argMin", "argMax".
1. If [=this=].{{MLGraphBuilder/[[hasBuilt]]}} is true, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/shape=][|axis|] is greater than |options|.{{MLArgMinMaxOptions/outputDataType}}'s maximum value, [=exception/throw=] a {{TypeError}}.
huningxin marked this conversation as resolved.
Show resolved Hide resolved
1. Let |outputShape| be the result of [=MLGraphBuilder/calculating reduction output sizes=] given |input|'s [=MLOperand/shape=], « |axis| », 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"}}.
1. Set |desc|.{{MLOperandDescriptor/dataType}} to |options|.{{MLArgMinMaxOptions/outputDataType}}.
1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |outputShape|.
1. *Make graph connections:*
1. Let |operator| be an [=operator=] for the |op| operation, given |options|.
Expand Down