FilesLast commitLast update
4 days ago
4 days ago
4 days ago
3 months ago
4 days ago
4 days ago
4 days ago
1 month ago
4 days ago
4 days ago
README

Trace

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: The Trace operator computes the sum of the main diagonal elements of a matrix, starting from the upper left corner.

  • Computation formula:

    y=sum(diag(x))y = sum(diag(x))

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Two-dimensional input tensor whose diagonal elements are summed, corresponding to x in the formula. COMPLEX64, FLOAT, FLOAT16, BFLOAT16, INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, BOOL ND
y Output Sum of the diagonal elements, corresponding to y in the formula. A UINT64 input produces a UINT64 output. COMPLEX64, FLOAT, FLOAT16, and BFLOAT16 inputs preserve their data type. All other inputs produce an INT64 output. COMPLEX64, FLOAT, FLOAT16, BFLOAT16, INT64, UINT64 ND
  • Atlas training products and Atlas inference products: The data types of x and y do not support BFLOAT16.

Constraint Description

  • x must be a two-dimensional Tensor, and y is a zero-dimensional scalar.
  • For a non-square matrix with shape (M,N)(M, N), the accumulated diagonal has a length of min⁡(M,N)\min(M, N).
  • Empty Tensors with shape (0,N)(0, N), (M,0)(M, 0), or (0,0)(0, 0) are supported and produce 0.

Invocation Description

Invocation Method Sample Code Description
aclnn API test_aclnn_trace Invokes the Trace operator through the aclnnTrace API.
GE graph mode test_geir_trace Invokes the Trace operator by building a graph through the operator IR.