abs_

Documentation

treetensor.torch.abs_(input)[source]

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

Examples:

>>> import torch
>>> import treetensor.torch as ttorch
>>> t = ttorch.tensor([12, 0, -3])
>>> ttorch.abs_(t)
>>> t
tensor([12,  0,  3])

>>> t = ttorch.tensor({
...     'a': [12, 0, -3],
...     'b': {'x': [[-3, 1], [0, -2]]},
... })
>>> ttorch.abs_(t)
>>> t
<Tensor 0x7f1c81d07ca0>
├── a --> tensor([12,  0,  3])
└── b --> <Tensor 0x7f1c81d07d30>
    └── x --> tensor([[3, 1],
                      [0, 2]])

Torch Version Related

This documentation is based on torch.abs_ in torch v2.4.1+cu121. 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__)'