ceil

Documentation

treetensor.torch.ceil(input, *args, **kwargs)[source]

Returns a tree of new tensors with the ceil of the elements of input, the smallest integer greater than or equal to each element.

Examples:

>>> import torch
>>> import treetensor.torch as ttorch
>>> ttorch.ceil(ttorch.tensor([[1.2, -1.8], [-2.3, 2.8]]))
tensor([[ 2., -1.],
        [-2.,  3.]])

>>> ttorch.ceil(ttorch.tensor({
...     'a': [[1.2, -1.8], [-2.3, 2.8]],
...     'b': {'x': [[1.0, -3.9, 1.3], [-4.8, -2.0, 2.8]]},
... }))
<Tensor 0x7f1c81d021c0>
├── a --> tensor([[ 2., -1.],
│                 [-2.,  3.]])
└── b --> <Tensor 0x7f1c81d02280>
    └── x --> tensor([[ 1., -3.,  2.],
                      [-4., -2.,  3.]])

Torch Version Related

This documentation is based on torch.ceil in torch v2.0.1+cu117. Its arguments’ arrangements depend on the version of pytorch you installed.

If some arguments listed here are not working properly, please check your pytorch’s version with the following command and find its documentation.

1
python -c 'import torch;print(torch.__version__)'

The arguments and keyword arguments supported in torch v2.0.1+cu117 is listed below.

Description From Torch v2.0.1+cu117

torch.ceil(input, *, out=None)Tensor

Returns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element.

\[\text{out}_{i} = \left\lceil \text{input}_{i} \right\rceil\]
Args:

input (Tensor): the input tensor.

Keyword args:

out (Tensor, optional): the output tensor.

Example:

>>> a = torch.randn(4)
>>> a
tensor([-0.6341, -1.4208, -1.0900,  0.5826])
>>> torch.ceil(a)
tensor([-0., -1., -1.,  1.])