mindspore.numpy.triu
- mindspore.numpy.triu(m, k=0)[source]
Returns an upper triangle of a tensor.
Returns a copy of a tensor with elements below the k-th diagonal zeroed.
- Parameters
- Returns
Upper triangle of m, of same shape and data-type as m.
- Raises
TypeError – If input arguments have types not specified above.
ValueError – If input m’s rank < 1.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> output = np.triu(np.ones((3, 3))) >>> print(output) [[1. 1. 1.] [0. 1. 1.] [0. 0. 1.]]