From f724533acff39bed8476970c8adb34f9a7d98f1c Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Wed, 4 Jun 2025 22:31:30 -0700 Subject: [PATCH 1/4] Add isNaN and isInfinite operators --- index.bs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 7117d8f8..fea63321 100644 --- a/index.bs +++ b/index.bs @@ -3362,6 +3362,8 @@ partial interface MLGraphBuilder { MLOperand logicalXor(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); + MLOperand isNaN(MLOperand a, optional MLOperatorOptions options = {}) + MLOperand isInfinite(MLOperand a, optional MLOperatorOptions options = {}) }; dictionary MLLogicalNotSupportLimits { @@ -3380,10 +3382,12 @@ partial dictionary MLOpSupportLimits { MLBinarySupportLimits logicalAnd; MLBinarySupportLimits logicalOr; MLBinarySupportLimits logicalXor; + MLBinarySupportLimits isNaN; + MLBinarySupportLimits isInfinite; }; -
+
**Arguments:** - a: an {{MLOperand}}. The first input tensor. - b: an {{MLOperand}}. The second input tensor when specified. @@ -3392,7 +3396,7 @@ partial dictionary MLOpSupportLimits { **Returns:** an {{MLOperand}}. The output tensor that contains the result of element-wise comparison of the two input tensors.
- +
@@ -3449,6 +3453,10 @@ partial dictionary MLOpSupportLimits { :: Support limits for operator {{MLGraphBuilder/logicalOr()}}. : logicalXor :: Support limits for operator {{MLGraphBuilder/logicalXor()}}. + : isNaN + :: Support limits for operator {{MLGraphBuilder/isNaN()}}. + : isInfinite + :: Support limits for operator {{MLGraphBuilder/isInfinite()}}.
@@ -3463,6 +3471,8 @@ partial dictionary MLOpSupportLimits { - *logicalAnd*: Compute the logical *and* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. - *logicalOr*: Compute the logical *or* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. - *logicalXor*: Compute the logical *xor* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. + - *isNaN*: Check if the values of the input tensor are invalid numberic representations (NaN's), element-wise, returning 1's for NaN's and 0 otherwise. + - *isInfinite*: Check if the values of the input tensor are infinite, element-wise, returning 1's for positive or negative infinity and 0 otherwise.
@@ -3473,7 +3483,7 @@ Although operations {{MLGraphBuilder/greaterOrEqual()}} and {{MLGraphBuilder/les To create an element-wise logical operation given [=string=] |op|, {{MLOperand}} |a|, an optional {{MLOperand}} |b|, and {{MLOperatorOptions}} |options|, run the following steps: - 1. [=Assert=]: |op| is one of "equal", "notEqual", "greater", "greaterOrEqual", "lesser", "lesserOrEqual", "logicalNot", "logicalAnd", "logicalOr", "logicalXor". + 1. [=Assert=]: |op| is one of "equal", "notEqual", "greater", "greaterOrEqual", "lesser", "lesserOrEqual", "logicalNot", "logicalAnd", "logicalOr", "logicalXor", "isNaN", "isInfinite". 1. If [=this=] [=MLGraphBuilder/can not build=], then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. If [=MLGraphBuilder/validating operand=] with [=this=] and |a| returns false, then [=exception/throw=] a {{TypeError}}. 1. If |op| is one of "logicalNot", "logicalAnd", "logicalOr", "logicalXor", then: @@ -3567,6 +3577,20 @@ Although operations {{MLGraphBuilder/greaterOrEqual()}} and {{MLGraphBuilder/les 1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error. 1. Return |output|.
+ +
+ The isNaN(|a|, |options|) method steps are: + 1. Let |output| be the result of [=MLGraphBuilder/element-wise-logical-op|creating an element-wise logical operation=] given "isNaN", |a|, and |options|. + 1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error. + 1. Return |output|. +
+ +
+ The isInfinite(|a|, |options|) method steps are: + 1. Let |output| be the result of [=MLGraphBuilder/element-wise-logical-op|creating an element-wise logical operation=] given "isInfinite", |a|, and |options|. + 1. If that [=exception/throws=] an error, then re-[=exception/throw=] the error. + 1. Return |output|. +
### Element-wise unary operations ### {#api-mlgraphbuilder-unary} From 381016c0dd75cafaa9095b65e99886885934d8ce Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Wed, 4 Jun 2025 22:39:22 -0700 Subject: [PATCH 2/4] Typo numberic --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index fea63321..c0c35f52 100644 --- a/index.bs +++ b/index.bs @@ -3471,7 +3471,7 @@ partial dictionary MLOpSupportLimits { - *logicalAnd*: Compute the logical *and* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. - *logicalOr*: Compute the logical *or* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. - *logicalXor*: Compute the logical *xor* of the two input tensors, element-wise, treating any non-zero value as true and returning elements of 0 or 1. - - *isNaN*: Check if the values of the input tensor are invalid numberic representations (NaN's), element-wise, returning 1's for NaN's and 0 otherwise. + - *isNaN*: Check if the values of the input tensor are invalid numeric representations (NaN's), element-wise, returning 1's for NaN's and 0 otherwise. - *isInfinite*: Check if the values of the input tensor are infinite, element-wise, returning 1's for positive or negative infinity and 0 otherwise. From 15f23a3a692a834ae35916ab688001db41f11941 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Wed, 4 Jun 2025 23:07:38 -0700 Subject: [PATCH 3/4] Fix missing semicolon after function prototype --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index c0c35f52..fc2efd87 100644 --- a/index.bs +++ b/index.bs @@ -3362,8 +3362,8 @@ partial interface MLGraphBuilder { MLOperand logicalXor(MLOperand a, MLOperand b, optional MLOperatorOptions options = {}); - MLOperand isNaN(MLOperand a, optional MLOperatorOptions options = {}) - MLOperand isInfinite(MLOperand a, optional MLOperatorOptions options = {}) + MLOperand isNaN(MLOperand a, optional MLOperatorOptions options = {}); + MLOperand isInfinite(MLOperand a, optional MLOperatorOptions options = {}); }; dictionary MLLogicalNotSupportLimits { From 3b51329c06fb5fb6b9990d47db6f330194e70ea3 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 5 Jun 2025 08:04:57 -0700 Subject: [PATCH 4/4] Fix support limits type for unary isNan and isInfinite --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index fc2efd87..9834bec4 100644 --- a/index.bs +++ b/index.bs @@ -3382,8 +3382,8 @@ partial dictionary MLOpSupportLimits { MLBinarySupportLimits logicalAnd; MLBinarySupportLimits logicalOr; MLBinarySupportLimits logicalXor; - MLBinarySupportLimits isNaN; - MLBinarySupportLimits isInfinite; + MLLogicalNotSupportLimits isNaN; + MLLogicalNotSupportLimits isInfinite; };
Constraints for element-wise logical options