Skip to content

Commit 994122f

Browse files
authored
Add roundEven operator (#859)
* Add roundEven operator * Update link-for
1 parent 4927ec5 commit 994122f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

index.bs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,6 +3765,7 @@ partial interface MLGraphBuilder {
37653765
MLOperand log(MLOperand input, optional MLOperatorOptions options = {});
37663766
MLOperand neg(MLOperand input, optional MLOperatorOptions options = {});
37673767
MLOperand reciprocal(MLOperand input, optional MLOperatorOptions options = {});
3768+
MLOperand roundEven(MLOperand input, optional MLOperatorOptions options = {});
37683769
MLOperand sin(MLOperand input, optional MLOperatorOptions options = {});
37693770
MLOperand sign(MLOperand input, optional MLOperatorOptions options = {});
37703771
MLOperand sqrt(MLOperand input, optional MLOperatorOptions options = {});
@@ -3782,14 +3783,15 @@ partial dictionary MLOpSupportLimits {
37823783
MLSingleInputSupportLimits log;
37833784
MLSingleInputSupportLimits neg;
37843785
MLSingleInputSupportLimits reciprocal;
3786+
MLSingleInputSupportLimits roundEven;
37853787
MLSingleInputSupportLimits sin;
37863788
MLSingleInputSupportLimits sign;
37873789
MLSingleInputSupportLimits sqrt;
37883790
MLSingleInputSupportLimits tan;
37893791
};
37903792
</script>
37913793

3792-
<div dfn-for="MLGraphBuilder/abs(input, options), MLGraphBuilder/ceil(input, options), MLGraphBuilder/cos(input, options), MLGraphBuilder/erf(input, options), MLGraphBuilder/exp(input, options), MLGraphBuilder/floor(input, options), MLGraphBuilder/identity(input, options), MLGraphBuilder/log(input, options), MLGraphBuilder/neg(input, options), MLGraphBuilder/reciprocal(input, options), MLGraphBuilder/sin(input, options), MLGraphBuilder/sign(input, options), MLGraphBuilder/sqrt(input, options), MLGraphBuilder/tan(input, options)" dfn-type=argument>
3794+
<div dfn-for="MLGraphBuilder/abs(input, options), MLGraphBuilder/ceil(input, options), MLGraphBuilder/cos(input, options), MLGraphBuilder/erf(input, options), MLGraphBuilder/exp(input, options), MLGraphBuilder/floor(input, options), MLGraphBuilder/identity(input, options), MLGraphBuilder/log(input, options), MLGraphBuilder/neg(input, options), MLGraphBuilder/reciprocal(input, options), MLGraphBuilder/roundEven(input, options), MLGraphBuilder/sin(input, options), MLGraphBuilder/sign(input, options), MLGraphBuilder/sqrt(input, options), MLGraphBuilder/tan(input, options)" dfn-type=argument>
37933795
**Arguments:**
37943796
- <dfn>input</dfn>: an {{MLOperand}}. The input tensor.
37953797
- <dfn>options</dfn>: an {{MLOperatorOptions}}. Specifies the optional parameters of the operation.
@@ -3799,7 +3801,7 @@ partial dictionary MLOpSupportLimits {
37993801
tensor is the same as the shape of input tensor.
38003802
</div>
38013803

3802-
<table id=constraints-elementwise-unary class='data' link-for="MLGraphBuilder/abs(input, options), MLGraphBuilder/ceil(input, options), MLGraphBuilder/cos(input, options), MLGraphBuilder/erf(input, options), MLGraphBuilder/exp(input, options), MLGraphBuilder/floor(input, options), MLGraphBuilder/identity(input, options), MLGraphBuilder/log(input, options), MLGraphBuilder/neg(input, options), MLGraphBuilder/reciprocal(input, options), MLGraphBuilder/sin(input, options), MLGraphBuilder/sign(input, options), MLGraphBuilder/sqrt(input, options), MLGraphBuilder/tan(input, options)">
3804+
<table id=constraints-elementwise-unary class='data' link-for="MLGraphBuilder/abs(input, options), MLGraphBuilder/ceil(input, options), MLGraphBuilder/cos(input, options), MLGraphBuilder/erf(input, options), MLGraphBuilder/exp(input, options), MLGraphBuilder/floor(input, options), MLGraphBuilder/identity(input, options), MLGraphBuilder/log(input, options), MLGraphBuilder/neg(input, options), MLGraphBuilder/reciprocal(input, options), MLGraphBuilder/roundEven(input, options), MLGraphBuilder/sin(input, options), MLGraphBuilder/sign(input, options), MLGraphBuilder/sqrt(input, options), MLGraphBuilder/tan(input, options)">
38033805
<caption>Constraints for element-wise unary options</caption>
38043806
<thead>
38053807
<tr>
@@ -3843,6 +3845,8 @@ partial dictionary MLOpSupportLimits {
38433845
:: Support limits for operator {{MLGraphBuilder/neg()}}.
38443846
: <dfn>reciprocal</dfn>
38453847
:: Support limits for operator {{MLGraphBuilder/reciprocal()}}.
3848+
: <dfn>roundEven</dfn>
3849+
:: Support limits for operator {{MLGraphBuilder/roundEven()}}.
38463850
: <dfn>sin</dfn>
38473851
:: Support limits for operator {{MLGraphBuilder/sin()}}.
38483852
: <dfn>sign</dfn>
@@ -3865,6 +3869,7 @@ partial dictionary MLOpSupportLimits {
38653869
- *log*: Compute the natural logarithm of the input tensor, element-wise.
38663870
- *neg*: Compute the numerical negative value of the input tensor, element-wise.
38673871
- *reciprocal*: Compute the reciprocal of the input tensor, element-wise.
3872+
- *roundEven*: Round the input tensor with halves to the nearest even value, element-wise (e.g. [0.1, 0.9, 1.1, 1.9, -3.5, -2.5, -1.5, 1.5, 2.5, 3.5] yields [0.0, 1.0, 1.0, 2.0, -4.0, -2.0, -2.0, 2.0, 2.0, 4.0]).
38683873
- *sin*: Compute the sine of the input tensor, element-wise.
38693874
- *sign*: Compute the sign (-1, 0, 1) of the input tensor, element-wise, returning 1 if > 0, -1 if < 0, and 0 otherwise.
38703875
- *sqrt*: Compute the square root of the input tensor, element-wise.
@@ -3875,7 +3880,7 @@ partial dictionary MLOpSupportLimits {
38753880
<summary>
38763881
To <dfn for="MLGraphBuilder" data-lt="element-wise-unary-op">create an element-wise unary operation</dfn> given [=string=] |op|, {{MLOperand}} |input|, optional [=/list=] |allowedDataTypes|, and |options|, run the following steps:
38773882
</summary>
3878-
1. [=Assert=]: |op| is one of "abs", "ceil", "cos", "erf", "exp", "floor", "identity", "log", "neg", "reciprocal", "sin", "sign", "sqrt", "tan".
3883+
1. [=Assert=]: |op| is one of "abs", "ceil", "cos", "erf", "exp", "floor", "identity", "log", "neg", "reciprocal", "roundEven", "sin", "sign", "sqrt", "tan".
38793884
1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
38803885
1. If [=MLGraphBuilder/validating operand=] with [=this=] and |input| returns false, then [=exception/throw=] a {{TypeError}}.
38813886
1. If |allowedDataTypes| is given and it does not [=list/contain=] |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
@@ -3962,6 +3967,13 @@ partial dictionary MLOpSupportLimits {
39623967
1. Return |output|.
39633968
</div>
39643969

3970+
<div algorithm>
3971+
The <dfn method for=MLGraphBuilder>roundEven(|input|, |options|)</dfn> method steps are:
3972+
1. Let |output| be the result of [=MLGraphBuilder/element-wise-unary-op|creating an element-wise unary operation=] given "roundEven", |input|, « {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}} », and |options|.
3973+
1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error.
3974+
1. Return |output|.
3975+
</div>
3976+
39653977
<div algorithm>
39663978
The <dfn method for=MLGraphBuilder>sin(|input|, |options|)</dfn> method steps are:
39673979
1. Let |output| be the result of [=MLGraphBuilder/element-wise-unary-op|creating an element-wise unary operation=] given "sin", |input|, « {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}} », and |options|.
@@ -4285,7 +4297,6 @@ partial dictionary MLOpSupportLimits {
42854297
<summary>
42864298
The behavior of this operation can be [EMULATED]
42874299
</summary>
4288-
This emulation relies on a pending `roundEven` operator in <#817>.
42894300
<pre highlight="js">
42904301
function quantizeLinear(builder, input, scale, zeroPoint, options) {
42914302
// output = clamp(roundEven(input / scale) + zeroPoint, 0, 255)

0 commit comments

Comments
 (0)