trunc

paddle. trunc ( input, name=None ) [source]

This API is used to returns a new tensor with the truncated integer values of input.

Parameters
  • input (Tensor) – The input tensor, it’s data type should be int32, int64, float32, float64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

The output Tensor of trunc.

Return type

Tensor

Examples

>>> import paddle

>>> input = paddle.to_tensor([[0.1, 1.5], [-0.2, -2.4]], 'float32')
>>> output = paddle.trunc(input)
>>> output
Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
[[ 0.,  1.],
 [-0., -2.]])