View Source Nx.Testing (Nx v0.10.0)

Testing functions for Nx tensor assertions.

This module provides functions for asserting tensor equality and approximate equality within specified tolerances.

Summary

Functions

Asserts that two tensors are approximately equal within the given tolerances.

Asserts that two tensors are exactly equal.

Functions

Link to this function

assert_all_close(left, right, opts \\ [])

View Source

Asserts that two tensors are approximately equal within the given tolerances.

See also:

  • Nx.all_close/2 - The underlying function that performs the comparison.

Options

  • :atol - The absolute tolerance. Defaults to 1.0e-4.
  • :rtol - The relative tolerance. Defaults to 1.0e-4.
Link to this function

assert_equal(left, right)

View Source

Asserts that two tensors are exactly equal.

This handles NaN values correctly by considering NaN == NaN as true.