From 9c96d6f91620e97a16d6547f105b2a2f49062d2d Mon Sep 17 00:00:00 2001 From: Phillis Tang Date: Mon, 15 Jul 2024 11:54:13 -0700 Subject: [PATCH] change argmin/argmax to take scalar axis --- index.bs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/index.bs b/index.bs index 8230e000..b9102604 100644 --- a/index.bs +++ b/index.bs @@ -1445,46 +1445,44 @@ Build a composed graph up to a given output operand into a computational graph a NOTE: Specifying an [=computational graph/input=] operand or [=computational graph/constant=] operand as a graph {{MLGraphBuilder/build(outputs)/outputs|output}} results in an error, as this is usually an incorrect usage of the API. Callers can work around this by introducing an {{MLGraphBuilder/identity()}} operator. ### argMin/argMax operations ### {#api-mlgraphbuilder-argminmax} -Return the index location of the minimum or maxmium values of all the input values along the axes. In case of ties, the identity of the return value is implementation dependent. +Return the index location of the minimum or maxmium values of all the input values along the axis. In case of ties, the identity of the return value is implementation dependent. {{MLArgMinMaxOptions}} has the following members:
- : axes - :: - The dimensions to reduce. The values must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensor. If not present, all dimensions are reduced. If empty, no dimensions are reduced, and the shape of the output tensor is the same as the shape of the input tensor. - : keepDimensions :: If true, retains reduced dimensions with [=list/size=] 1.
-
+
**Arguments:** - input: an {{MLOperand}}. The input N-D tensor. + - axis: The dimension to reduce. The value must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensor. - options: 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 corresponding size of each of the input dimensions specified by options.axes. + **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.
- To create argMin/argMax operation given [=string=] |op|, {{MLOperand}} |input| and {{MLArgMinMaxOptions}} |options|, run the following steps: + To create argMin/argMax operation given [=string=] |op|, {{MLOperand}} |input|, {{unsigned long}} |axis|, and {{MLArgMinMaxOptions}} |options|, run the following steps: 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. 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 |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/dimensions}} to |outputShape|. @@ -1502,15 +1500,15 @@ partial interface MLGraphBuilder { The following argMin/argMax algorithms are supported.
- The argMin(|input|, |options|) method steps are: - 1. Let |output| be the result of running the [=MLGraphBuilder/argminmax-op | create argMin/argMax operation=] given "argMin", |input| and |options|. + The argMin(|input|, |axis|, |options|) method steps are: + 1. Let |output| be the result of running the [=MLGraphBuilder/argminmax-op | create argMin/argMax operation=] given "argMin", |input|, |axis| and |options|. 1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error. 1. Return |output|.
- The argMax(|input|, |options|) method steps are: - 1. Let |output| be the result of running the [=MLGraphBuilder/argminmax-op | create argMin/argMax operation=] given "argMax", |input| and |options|. + The argMax(|input|, |axis|, |options|) method steps are: + 1. Let |output| be the result of running the [=MLGraphBuilder/argminmax-op | create argMin/argMax operation=] given "argMax", |input|, |axis| and |options|. 1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error. 1. Return |output|.
@@ -5576,7 +5574,7 @@ partial interface MLGraphBuilder {
- The softplus() method steps are: + The softplus() method steps are: 1. Let |op| be the result of [=creating an MLActivation=] given [=this=] and "softplus". 1. Return |op|.