mlx.core.trace

目录

mlx.core.trace#

trace(a: array, /, offset: int = 0, axis1: int = 0, axis2: int = 1, dtype: Dtype | None = None, *, stream: None | Stream | Device = None) array#

Return the sum along a specified diagonal in the given array.

参数:
  • a (array) -- Input array

  • offset (int, optional) -- Offset of the diagonal from the main diagonal. Can be positive or negative. Default: 0.

  • axis1 (int, optional) -- The first axis of the 2-D sub-arrays from which the diagonals should be taken. Default: 0.

  • axis2 (int, optional) -- The second axis of the 2-D sub-arrays from which the diagonals should be taken. Default: 1.

  • dtype (Dtype, optional) -- Data type of the output array. If unspecified the output type is inferred from the input array.

返回:

Sum of specified diagonal.

返回类型:

array