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 in input and other :

\(|\text{input}_i - \text{other}_i| <= (\text{atol} + \text{rtol} * |\text{other}_i|)\)

Parameters:
  • input (Tensor) – [dtype=T1] First tensor to compare.

  • other (Tensor) – [dtype=T1] Second tensor to compare.

  • rtol (float) – The relative tolerance.

  • atol (float) – The absolute tolerance.

Returns:

True if the tensors were within the specified tolerances and False otherwise.

Return type:

bool

TYPE CONSTRAINTS:
Example: Within Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.1e-7]))
Local Variables
>>> out
True
Example: Outside Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.2e-7]))
Local Variables
>>> out
False