FilesLast commitLast update
2 months ago
8 days ago
3 days ago
6 months ago
8 days ago
3 days ago
1 month ago
14 days ago
README

Diag

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function Description

  • Operator function: expands the diagonal elements of the input tensor (flattened and viewed as 1D) into a 2D diagonal matrix

  • Computation formula:

    Suppose:

    x∈Rn : input vector\mathbf{x} \in \mathbb{R}^n \text{ : input vector}

    y∈Rn×n : output diagonal matrix\mathbf{y} \in \mathbb{R}^{n \times n} \text{ : output diagonal matrix}

    where:

    yi,i=xi\mathbf{y}_{i,i} = x_i

    yi,j=0 when i≠j\mathbf{y}_{i,j} = 0 \text{ when } i \ne j

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input x in the formula. INT64, INT32, FLOAT, FLOAT16, DOUBLE, BF16, COMPLEX64, COMPLEX128 ND
y Output y in the formula. INT64, INT32, FLOAT, FLOAT16, DOUBLE, BF16, COMPLEX64, COMPLEX128 ND
  • Atlas training products, Atlas inference products, Atlas 200I/500 A2 inference products, Atlas A2 products, and Atlas A3 products: BF16 is not supported.

Constraint Description

Only input shapes with 1 to 4 dimensions are supported, which correspond to outputs with 2 to 8 dimensions. Scalar inputs are not supported.

Invocation Description

Invocation Method Invocation Sample Description
Graph-mode invocation NA Invokes the diag operator by building a graph through the operator IR