mindspore.ops.trunc

mindspore.ops.trunc(input_x)[source]

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

Parameters

input_x (Tensor) – input_x is a tensor.

Returns

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

Raises

TypeError – If input_x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([3.4742, 0.5466, -0.8008, -3.9079]),mindspore.float32)
>>> output = ops.trunc(input_x)
>>> print(output)
[ 3. 0. 0. -3.]