floor_divide

paddle. floor_divide ( x: Tensor, y: Tensor, name: str | None = None ) Tensor [source]

Floor divide two tensors element-wise and rounds the quotinents to the nearest integer toward negative infinite. The equation is:

\[out = floor(x / y)\]
  • \(x\): Multidimensional Tensor.

  • \(y\): Multidimensional Tensor.

Note

paddle.floor_divide supports broadcasting. If you want know more about broadcasting, please refer to Introduction to Tensor .

Parameters
  • x (Tensor) – the input tensor, it’s data type should be uint8, int8, int32, int64, float32, float64, float16, bfloat16.

  • y (Tensor) – the input tensor, it’s data type should be uint8, int8, int32, int64, float32, float64, float16, bfloat16.

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

Returns

N-D Tensor. A location into which the result is stored. It’s dimension equals with $x$.

Examples

>>> import paddle

>>> x = paddle.to_tensor([2, 3, 8, 7])
>>> y = paddle.to_tensor([1, 5, 3, 3])
>>> z = paddle.floor_divide(x, y)
>>> print(z)
Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
[2, 0, 2, 2])

>>> x = paddle.to_tensor([2, 3, 8, 7])
>>> y = paddle.to_tensor([1, -5, -3, -3])
>>> z = paddle.floor_divide(x, y)
>>> print(z)
Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
[2, -1, -3, -3])