Skip to content

Commit 3cef040

Browse files
Content: The input of triangular should be at least 2D tensor
Fixes #494
1 parent d1a02f2 commit 3cef040

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

index.bs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5873,7 +5873,7 @@ partial interface MLGraphBuilder {
58735873
</details>
58745874

58755875
### triangular ### {#api-mlgraphbuilder-triangular}
5876-
Given a 2-D tensor (matrix), return a 2-D tensor containing either the upper or lower triangular part of the input tensor.
5876+
Given a 2-D tensor (matrix), return a 2-D tensor containing either the upper or lower triangular part of the input tensor. If the input tensor has greater than 2 dimensions it is treated as a batch of matrices and the result has the same shape.
58775877

58785878
<script type=idl>
58795879
dictionary MLTriangularOptions {
@@ -5898,17 +5898,18 @@ partial interface MLGraphBuilder {
58985898

58995899
<div>
59005900
**Arguments:**
5901-
- *input*: an {{MLOperand}}. The input 2-D tensor.
5901+
- *input*: an {{MLOperand}}. The input tensor which is at least 2-D.
59025902
- *options*: an optional {{MLTriangularOptions}}. The optional parameters of the operation.
59035903

5904-
**Returns:** an {{MLOperand}}. The output 2-D tensor representing a triangular matrix.
5904+
**Returns:** an {{MLOperand}}. The output tensor representing a triangular matrix, or batch of matrices which is the same shape as the input.
59055905
</div>
59065906

59075907
<details open algorithm>
59085908
<summary>
59095909
The <dfn method for=MLGraphBuilder>triangular(|input|, |options|)</dfn> method steps are:
59105910
</summary>
59115911
<div class=algorithm-steps>
5912+
1. If the [=list/size=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is less than 2, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
59125913
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
59135914
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
59145915
1. Make a request to the underlying platform to:
@@ -5969,7 +5970,16 @@ partial interface MLGraphBuilder {
59695970
// [[0, 0, 0],
59705971
// [9, 0, 0],
59715972
// [2, 6, 0]]
5972-
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 });
5973+
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 })
5974+
5975+
// lower triangular matrix with two batches:
5976+
// [[[7, 0, 0],
5977+
// [9, 4, 0],
5978+
// [2, 6, 3]],
5979+
// [[1, 0, 0],
5980+
// [4, 5, 0],
5981+
// [7, 8, 9]]]
5982+
const lowerWithBatches = builder.triangular(input, { upper: false });
59735983
</pre>
59745984
</details>
59755985
</div>

0 commit comments

Comments
 (0)