# trace¶

static OperationNamespace.trace(x, *, name=None)

Returns the sum of the diagonals of each innermost matrix of the input tensor.

Parameters
• x (np.ndarray or Tensor) – The matrix whose trace you want to calculate, $$x$$.

• name (str, optional) – The name of the node.

Returns

The trace of the input tensor $$\mathop{\mathrm{Tr}}(x)$$.

Return type

Tensor