mindspore.ops.Trunc

class mindspore.ops.Trunc[source]

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

Refer to mindspore.ops.trunc() for more details.

Inputs:
  • input_x (Tensor) - Input tensor of any dimension.

Outputs:

Tensor, the same shape and data type as input_x.

Supported Platforms:

Ascend GPU CPU

Examples

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