log2_

Documentation

treetensor.torch.log2_(input)[source]

In-place version of log2().

Examples:

>>> import torch
>>> import treetensor.torch as ttorch
>>> t = ttorch.tensor([-4.0, -1.0, 0, 2.0, 4.8, 8.0])
>>> ttorch.log2_(t)
>>> t
tensor([   nan,    nan,   -inf, 1.0000, 2.2630, 3.0000])

>>> t = ttorch.tensor({
...     'a': [-4.0, -1.0, 0, 2.0, 4.8, 8.0],
...     'b': {'x': [[-2.0, 1.2, 0.25],
...                 [16.0, 3.75, -2.34]]},
... })
>>> ttorch.log2_(t)
>>> t
<Tensor 0x7ff90a4cbbe0>
├── a --> tensor([   nan,    nan,   -inf, 1.0000, 2.2630, 3.0000])
└── b --> <Tensor 0x7ff90a4cb940>
    └── x --> tensor([[    nan,  0.2630, -2.0000],
                      [ 4.0000,  1.9069,     nan]])

Torch Version Related

This documentation is based on torch.log2_ 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__)'