PyTorch .floor_divide()
Anonymous contributor
Published Aug 27, 2025
Contribute to Docs
In PyTorch, the .floor_divide() function divides the input by other element-wise and rounds each quotient down to the nearest integer, returning the floored result as a tensor. It supports broadcasting, type promotion, and both integer and floating-point operands. The operation can be expressed as:
$$\text{out}_i = \text{floor}(\frac{\text{input}_i}{\text{other}_i})$$
Syntax
torch.floor_divide(input, other, *, out=None) → Tensor
Parameters:
input: The input tensor(dividend).other: Tensor or Number(divisor).out(Optional): A tensor to store the output. If provided, the result is written to this tensor.
Return value:
It returns a new tensor of the same shape as the input, containing the result of element-wise division and rounds the result of the division down to the nearest integer.
Example
In this example, we use floor_divide() to perform divison of two tensors x and y :
import torchx = torch.tensor([4.0, 3.0])y = torch.tensor([2.0, 2.0])print(torch.floor_divide(x, y))
The output of this code is:
tensor([2., 1.])
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PyTorch on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use PyTorch to build, train, and test artificial neural networks in this course.
- Intermediate.3 hours