ge

Documentation

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

In treetensor, you can get greater-than-or-equal situation of the two tree tensors with ge().

Examples:

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

>>> ttorch.ge(
...     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 0x7ff363bc6f28>
├── a --> tensor([[ True,  True],
│                 [False,  True]])
└── b --> tensor([False,  True,  True])

Torch Version Related

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

The arguments and keyword arguments supported in torch v2.4.1+cu121 is listed below.

Description From Torch v2.4.1+cu121

torch.ge(input, other, *, out=None)Tensor

Computes \(\text{input} \geq \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 greater than or equal to other and False elsewhere

Example:

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