Skip to content

Commit 5a6869e

Browse files
authored
Merge pull request #550 from inexorabletash/content-triangular-atleast2d
Content: The input of triangular should be at least 2D tensor
2 parents bec8e7e + 3cef040 commit 5a6869e

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
@@ -5729,7 +5729,7 @@ partial interface MLGraphBuilder {
57295729
</details>
57305730

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

57345734
<script type=idl>
57355735
dictionary MLTriangularOptions {
@@ -5754,17 +5754,18 @@ partial interface MLGraphBuilder {
57545754

57555755
<div>
57565756
**Arguments:**
5757-
- *input*: an {{MLOperand}}. The input 2-D tensor.
5757+
- *input*: an {{MLOperand}}. The input tensor which is at least 2-D.
57585758
- *options*: an optional {{MLTriangularOptions}}. The optional parameters of the operation.
57595759

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

57635763
<details open algorithm>
57645764
<summary>
57655765
The <dfn method for=MLGraphBuilder>triangular(|input|, |options|)</dfn> method steps are:
57665766
</summary>
57675767
<div class=algorithm-steps>
5768+
1. If the [=list/size=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is less than 2, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
57685769
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
57695770
1. Let |output| be the result of [=copying an MLOperand=] given |input|.
57705771
1. Make a request to the underlying platform to:
@@ -5825,7 +5826,16 @@ partial interface MLGraphBuilder {
58255826
// [[0, 0, 0],
58265827
// [9, 0, 0],
58275828
// [2, 6, 0]]
5828-
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 });
5829+
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 })
5830+
5831+
// lower triangular matrix with two batches:
5832+
// [[[7, 0, 0],
5833+
// [9, 4, 0],
5834+
// [2, 6, 3]],
5835+
// [[1, 0, 0],
5836+
// [4, 5, 0],
5837+
// [7, 8, 9]]]
5838+
const lowerWithBatches = builder.triangular(input, { upper: false });
58295839
</pre>
58305840
</details>
58315841
</div>

0 commit comments

Comments
 (0)