lt

Documentation

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

In treetensor, you can get less-than situation of the two tree tensors with lt().

Examples:

>>> import torch
>>> import treetensor.torch as ttorch
>>> ttorch.lt(
...     torch.tensor([[1, 2], [3, 4]]),
...     torch.tensor([[1, 1], [4, 4]]),
... )
tensor([[False, False],
        [ True, False]])

>>> ttorch.lt(
...     ttorch.tensor({
...         'a': [[1, 2], [3, 4]],
...         'b': [1.0, 1.5, 2.0],
...     }),
...     ttorch.tensor({
...         'a': [[1, 1], [4, 4]],
...         'b': [1.3, 1.2, 2.0],
...     }),
... )
<Tensor 0x7ff363bc67f0>
├── a --> tensor([[False, False],
│                 [ True, False]])
└── b --> tensor([ True, False, False])

Torch Version Related

This documentation is based on torch.lt 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.lt(input, other, *, out=None)Tensor

Computes \(\text{input} < \text{other}\) element-wise.

The second argument can be a number or a tensor whose shape is broadcastable with the first argument.

Args:

input (Tensor): the tensor to compare other (Tensor or float): the tensor or value to compare

Keyword args:

out (Tensor, optional): the output tensor.

Returns:

A boolean tensor that is True where input is less than other and False elsewhere

Example:

>>> torch.lt(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]]))
tensor([[False, False], [True, False]])