mindspore.mint.trunc

View Source On Gitee
mindspore.mint.trunc(input)[source]

Returns a new tensor with the truncated integer values of the elements of the input tensor.

Parameters

input (Tensor) – The input tensor.

Returns

Tensor, the same shape and data type as the input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> x = Tensor(np.array([3.4742, 0.5466, -0.8008, -3.9079]),mindspore.float32)
>>> output = mint.trunc(x)
>>> print(output)
[3. 0. 0. -3.]