round_

Documentation

treetensor.torch.round_(input)[source]

In-place version of treetensor.torch.round().

Examples:

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

>>> t = 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]]},
... })
>>> ttorch.round_(t)
>>> t
<Tensor 0x7fbf5332a460>
├── a --> tensor([[ 1., -2.],
│                 [-2.,  3.]])
└── b --> <Tensor 0x7fbf5332a1f0>
    └── x --> tensor([[ 1., -4.,  1.],
                      [-5., -2.,  3.]])

Torch Version Related

This documentation is based on torch.round_ in torch v1.10.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__)'