allclose¶
- nvtripy.allclose(input: Tensor, other: Tensor, rtol: float = 1e-05, atol: float = 1e-08) bool [source]¶
Returns
True
if the following equation is true for every element ininput
andother
:\(|\text{input}_i - \text{other}_i| <= (\text{atol} + \text{rtol} * |\text{other}_i|)\)
- Parameters:
- Returns:
True
if the tensors were within the specified tolerances andFalse
otherwise.- Return type:
Example: Within Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.1e-7]))
>>> out True
Example: Outside Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.2e-7]))
>>> out False