Skip to content

Commit 5a7ae65

Browse files
Content: The input of triangular should be at least 2D tensor
Fixes #494
1 parent 479ce17 commit 5a7ae65

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

index.bs

+14-4
Original file line numberDiff line numberDiff line change
@@ -5912,7 +5912,7 @@ partial interface MLGraphBuilder {
59125912
</details>
59135913

59145914
### triangular ### {#api-mlgraphbuilder-triangular}
5915-
Given a 2-D tensor (matrix), return a 2-D tensor containing either the upper or lower triangular part of the input tensor.
5915+
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.
59165916

59175917
<script type=idl>
59185918
dictionary MLTriangularOptions {
@@ -5937,17 +5937,18 @@ partial interface MLGraphBuilder {
59375937

59385938
<div>
59395939
**Arguments:**
5940-
- *input*: an {{MLOperand}}. The input 2-D tensor.
5940+
- *input*: an {{MLOperand}}. The input tensor which is at least 2-D.
59415941
- *options*: an optional {{MLTriangularOptions}}. The optional parameters of the operation.
59425942

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

59465946
<details open algorithm>
59475947
<summary>
59485948
The <dfn method for=MLGraphBuilder>triangular(|input|, |options|)</dfn> method steps are:
59495949
</summary>
59505950
<div class=algorithm-steps>
5951+
1. If the [=list/size=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is less than 2, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
59515952
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
59525953
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
59535954
1. Make a request to the underlying platform to:
@@ -6008,7 +6009,16 @@ partial interface MLGraphBuilder {
60086009
// [[0, 0, 0],
60096010
// [9, 0, 0],
60106011
// [2, 6, 0]]
6011-
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 });
6012+
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 })
6013+
6014+
// lower triangular matrix with two batches:
6015+
// [[[7, 0, 0],
6016+
// [9, 4, 0],
6017+
// [2, 6, 3]],
6018+
// [[1, 0, 0],
6019+
// [4, 5, 0],
6020+
// [7, 8, 9]]]
6021+
const lower = builder.triangular(input, { upper: false });
60126022
</pre>
60136023
</details>
60146024
</div>

0 commit comments

Comments
 (0)