Skip to content

Created .ceil() entry for PyTorch #7030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions content/pytorch/concepts/tensor-operations/terms/ceil/ceil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
Title: '.ceil()'
Description: 'Returns a new tensor with the smallest integer greater than or equal to each element of the input tensor.'
Subjects:
- 'Computer Science'
- 'Machine Learning'
Tags:
- 'Python'
- 'Machine Learning'
- 'Functions'
- 'Values'
CatalogContent:
- 'intro-to-py-torch-and-neural-networks'
- 'paths/computer-science'
---

In PyTorch, the **`.ceil()`** function returns a new tensor with the smallest integer greater than or equal to each element of the input tensor.

## Syntax

```pseudo
torch.ceil(input,*, out=None)
```

- `input`: the primary parameter, representing the tensor whose elements you want to apply the ceiling operation to

- `out`: an optional keyword argument. If you provide an existing tensor here, the result of the `ceil` operation will be stored in this `out`tensor. This can be useful for memory optimization if you want to reuse an existing tensor

## Example

```py
import torch

# Create a tensor
x = torch.tensor([1.2, -0.8, 3.0, -2.7, 5.5])

# Apply the ceil operation
y = torch.ceil(x)

print(f"Original tensor: {x}")
print(f"Ceil tensor: {y}")
```

The above program gives the following output:

```shell
Original tensor: tensor([1.2000, -0.8000, 3.0000, -2.7000, 5.5000])
Ceil tensor: tensor([2., -0.0000, 3., -2., 6.])
```