mindspore.ops.trunc

mindspore.ops.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 GPU CPU

Examples

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