Skip to content

Commit

Permalink
tri -> triangular
Browse files Browse the repository at this point in the history
  • Loading branch information
wchao1115 committed Nov 11, 2023
1 parent 00c355c commit cfcbca0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5737,22 +5737,22 @@ partial interface MLGraphBuilder {
</div>
</details>

### {{MLGraphBuilder/tri}} ### {#api-mlgraphbuilder-tri}
### {{MLGraphBuilder/triangular}} ### {#api-mlgraphbuilder-triangular}
Given a 2-D tensor (matrix), return a 2-D tensor containing either the upper or lower triangular part of the input tensor.

<script type=idl>
dictionary MLTriOptions {
dictionary MLTriangularOptions {
boolean upper = true;
long diagonal = 0;
};

partial interface MLGraphBuilder {
MLOperand tri(MLOperand input, optional MLTriOptions options = {});
MLOperand triangular(MLOperand input, optional MLTriangularOptions options = {});
};
</script>

{{MLTriOptions}} has the following members:
<dl dfn-type=dict-member dfn-for=MLTriOptions>
{{MLTriangularOptions}} has the following members:
<dl dfn-type=dict-member dfn-for=MLTriangularOptions>
: <dfn>upper</dfn>
::
A {{boolean}} value. Indicate whether the output the upper or the lower part of the input matrix is retained. If not set, it is assumed to be true, indicating that the upper part is retained.
Expand All @@ -5764,20 +5764,20 @@ partial interface MLGraphBuilder {
<div>
**Arguments:**
- *input*: an {{MLOperand}}. The input 2-D tensor.
- *options*: an optional {{MLTriOptions}}. The optional parameters of the operation.
- *options*: an optional {{MLTriangularOptions}}. The optional parameters of the operation.

**Returns:** an {{MLOperand}}. The output 2-D tensor representing a triangular matrix.
</div>

<details open algorithm>
<summary>
The <dfn method for=MLGraphBuilder>tri(|input|, |options|)</dfn> method steps are:
The <dfn method for=MLGraphBuilder>triangular(|input|, |options|)</dfn> method steps are:
</summary>
<div class=algorithm-steps>
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1. Let |output| be the result of <a>copying an MLOperand</a> given |input|.
1. Make a request to the underlying platform to:
1. Let |opImpl| be an [=implementation-defined=] platform operator for the tri operation, given |options|.
1. Let |opImpl| be an [=implementation-defined=] platform operator for the triangular operation, given |options|.
1. Store a reference of |opImpl| in |output|.{{MLOperand/[[operator]]}}.
1. Create an [=implementation-defined=] platform operand |outputImpl| to represent the output, given |output| and |opImpl|.
1. Store a reference to |outputImpl| in |output|.{{MLOperand/[[operand]]}}.
Expand All @@ -5790,7 +5790,7 @@ partial interface MLGraphBuilder {
<div class="example">
<details open>
<summary>
Examples of how tri works in different diagonal settings.
Examples of how triangular works in different diagonal settings.
</summary>
<pre highlight="js">
// input:
Expand All @@ -5804,37 +5804,37 @@ partial interface MLGraphBuilder {
// [[7, 1, 2],
// [0, 4, 8],
// [0, 0, 3]]
const upper = builder.tri(input);
const upper = builder.triangular(input);

// upper triangular matrix with one additional set of diagonals excluded:
// [[0, 1, 2],
// [0, 0, 8],
// [0, 0, 0]]
const upperPositive = builder.tri(input, { diagonal: 1 });
const upperPositive = builder.triangular(input, { diagonal: 1 });

// upper triangular matrix with one additional set of diagonals retained:
// [[7, 1, 2],
// [9, 4, 8],
// [0, 6, 3]]
const upperNegative = builder.tri(input, { diagonal: -1 });
const upperNegative = builder.triangular(input, { diagonal: -1 });

// lower triangular matrix:
// [[7, 0, 0],
// [9, 4, 0],
// [2, 6, 3]]
const lower = builder.tri(input, { upper: false });
const lower = builder.triangular(input, { upper: false });

// lower triangular matrix with one additional set of diagonals retained:
// [[7, 1, 0],
// [9, 4, 8],
// [2, 6, 3]]
const lowerPositive = builder.tri(input, { upper: false, diagonal: 1 });
const lowerPositive = builder.triangular(input, { upper: false, diagonal: 1 });

// lower triangular matrix with one additional set of diagonals excluded:
// [[0, 0, 0],
// [9, 0, 0],
// [2, 6, 0]]
const lowerNegative = builder.tri(input, { upper: false, diagonal: -1 });
const lowerNegative = builder.triangular(input, { upper: false, diagonal: -1 });
</pre>
</details>
</div>
Expand Down

0 comments on commit cfcbca0

Please sign in to comment.