oneflow.isclose¶
-
oneflow.
isclose
(input, other, atol=1e-08, rtol=1e-05, equal_nan=False) → Tensor¶ The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.isclose.html
Returns a new tensor with boolean elements representing if each element of
input
is “close” to the corresponding element ofother
. Closeness is defined as:\[\lvert \text{input} - \text{other} \rvert \leq \texttt{atol} + \texttt{rtol} \times \lvert \text{other} \rvert\]- Parameters
input (oneflow.Tensor) – first tensor to compare
other (oneflow.Tensor) – second tensor to compare
atol (float, optional) – absolute tolerance. Default: 1e-08
rtol (float, optional) – relative tolerance. Default: 1e-05
equal_nan (bool, optional) – if
True
, then twoNaN
s will be considered equal. Default:False
- Returns
A Tensor with bool type.
- Return type
For example:
>>> import oneflow as flow >>> flow.isclose(flow.tensor((1., 2, 3)), flow.tensor((1 + 1e-10, 3, 4))) tensor([ True, False, False], dtype=oneflow.bool) >>> flow.isclose(flow.tensor((float('inf'), 4)), flow.tensor((float('inf'), 6)), rtol=.5) tensor([True, True], dtype=oneflow.bool)