mindspore.numpy.tril_indices_from

mindspore.numpy.tril_indices_from(arr, k=0)[source]

Returns the indices for the lower-triangle of arr.

Parameters
  • arr (Union[Tensor, list, tuple]) – 2-dimensional array.

  • k (int, optional) – Diagonal offset.

Returns

triu_indices_from, tuple of 2 tensor, shape(N) Indices for the upper-triangle of arr.

Raises
  • TypeError – if arr cannot be converted to tensor, or k is not a number.

  • ValueError – if arr cannot be converted to a 2-dimensional tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> tensor = np.ones((3,3))
>>> print(np.tril_indices_from(tensor))
(Tensor(shape=[6], dtype=Int32, value= [0, 1, 1, 2, 2, 2]),
 Tensor(shape=[6], dtype=Int32, value= [0, 0, 1, 0, 1, 2]))