oneflow.allclose¶
-
oneflow.
allclose
(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) → bool¶ The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.allclose.html
This function checks if
input
andother
satisfy the condition:\[\lvert \text{input} - \text{other} \rvert \leq \texttt{atol} + \texttt{rtol} \times \lvert \text{other} \rvert\]elementwise, for all elements of
input
andother
. The behaviour of this function is analogous to numpy.allclose- 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.allclose(flow.tensor([10000., 1e-07]), flow.tensor([10000.1, 1e-08])) False >>> flow.allclose(flow.tensor([10000., 1e-08]), flow.tensor([10000.1, 1e-09])) True >>> flow.allclose(flow.tensor([1.0, float('nan')]), flow.tensor([1.0, float('nan')])) False >>> flow.allclose(flow.tensor([1.0, float('nan')]), flow.tensor([1.0, float('nan')]), equal_nan=True) True