allclose

tripy.allclose(a: Tensor, b: Tensor, rtol: float = 1e-05, atol: float = 1e-08) bool[source]

Returns true if the following equation is true for every element in a and b :

\(|a_i - b_i| <= (\text{atol} + \text{rtol} * |b_i|)\)

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

  • b (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
Within Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.1e-7]))
>>> out
True
Example: Outside Tolerance
Outside Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.2e-7]))
>>> out
False