FilesLast commitLast update
10 days ago
13 days ago
13 days ago
13 days ago
13 days ago
13 days ago
5 days ago
22 days ago
5 days ago
5 days ago
README

DiagFlat

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 √
Kirin X90 processor series products √
Kirin 9030 processor series products √

Function Description

  • Operator function: generates a diagonal tensor. If the input self is a one-dimensional tensor, a two-dimensional tensor is returned, where the elements of self are the diagonal values. If the input self is a tensor with two or more dimensions, it is first flattened (reduced to a one-dimensional tensor) and then processed as in the first scenario.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
self Input tensor Vector to be filled into the diagonal. At most 8 dimensions are supported, and non-contiguous Tensors are supported. FLOAT, FLOAT16, DOUBLE, INT32, INT64, INT16, INT8, UINT8, BOOL, COMPLEX64, BFLOAT16 ND
diagonal Optional attribute Specifies the diagonal position. The default value is 0. diagonal = 0 indicates the main diagonal, diagonal > 0 indicates a diagonal above the main diagonal, and diagonal < 0 indicates a diagonal below the main diagonal. INT64 -
out Output tensor Output diagonal tensor. FLOAT, FLOAT16, DOUBLE, INT32, INT64, INT16, INT8, UINT8, BOOL, COMPLEX64, BFLOAT16 ND
  • Kirin X90/Kirin 9030 processor series products: the self and out data types do not support COMPLEX or BFLOAT16.
  • Atlas training products and Atlas inference products: BFLOAT16 is not supported.

Constraint Description

  • When the input self is a one-dimensional tensor, the output is a two-dimensional square matrix with side length n = numel(self) + |diagonal|. When self is a tensor with two or more dimensions, it is first flattened and then processed as one-dimensional, and the output is also a two-dimensional square matrix.
  • Empty Tensors (numel(self) = 0) are supported: if |diagonal| > 0, the output is an all-zero square matrix of |diagonal| × |diagonal|; if |diagonal| = 0, the output is 0 × 0.
  • The value of diagonal must satisfy that numel(self) + |diagonal| does not exceed the upper limit of the int64 output size. If diagonal is INT64_MIN, the input is rejected as an invalid parameter.

Invocation Description

Invocation Method Sample Code Description
aclnn API test_aclnn_diag_flat Invokes the DiagFlat operator through the aclnnDiagFlat API.
GE graph-mode invocation - Invokes the DiagFlat operator by building a graph through the operator IR.