floor

Documentation

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

Returns a tree of new tensors with the floor of the elements of input, the largest integer less than or equal to each element.

Examples:

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

>>> ttorch.floor(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 0x7fbf53334250>
├── a --> tensor([[ 1., -2.],
│                 [-3.,  2.]])
└── b --> <Tensor 0x7fbf53334f10>
    └── x --> tensor([[ 1., -4.,  1.],
                      [-5., -2.,  2.]])

Torch Version Related

This documentation is based on torch.floor in torch v1.9.0+cu102. 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 v1.9.0+cu102 is listed below.

Description From Torch v1.9.0+cu102

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

Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element.

\[\text{out}_{i} = \left\lfloor \text{input}_{i} \right\rfloor\]
Args:

input (Tensor): the input tensor.

Keyword args:

out (Tensor, optional): the output tensor.

Example:

>>> a = torch.randn(4)
>>> a
tensor([-0.8166,  1.5308, -0.2530, -0.2091])
>>> torch.floor(a)
tensor([-1.,  1., -1., -1.])