tenzr::check¶
Classes¶
| Name | |
|---|---|
| struct | tenzr::check::DeviceTestTarget A test device target pairing its name with whether it is available on this machine. |
| class | tenzr::check::HardwareHarness Test helper that discovers available device targets and runs a test body once per target. |
Functions¶
| Name | |
|---|---|
| void | AssertShape(const Tensor & t, const Shape & expected, const char * file, int line) |
| void | AssertDtype(const Tensor & t, DType expected, const char * file, int line) |
| void | AssertDevice(const Tensor & t, const std::string & expected_device, const char * file, int line) |
| void | AssertClose(const Tensor & actual, const Tensor & expected, double rtol, double atol, const char * file, int line) |
| void | AssertClose(const Tensor & actual, const Tensor & expected, const char * file, int line) |
Functions Documentation¶
function AssertShape¶
Parameters:
- t The tensor to inspect.
- expected The expected shape.
- file Source file, supplied by the assertion macro.
- line Source line, supplied by the assertion macro.
- t Tensor to test.
- expected Required shape.
- file Source file reported in the failure message.
- line Source line reported in the failure message.
Asserts that a tensor's shape equals expected, throwing on mismatch. Assert that t has exactly the expected shape, throwing on mismatch.
function AssertDtype¶
Parameters:
- t The tensor to inspect.
- expected The expected dtype.
- file Source file, supplied by the assertion macro.
- line Source line, supplied by the assertion macro.
- t Tensor to test.
- expected Required dtype.
- file Source file reported in the failure message.
- line Source line reported in the failure message.
Asserts that a tensor's dtype equals expected, throwing on mismatch. Assert that t has exactly the expected dtype, throwing on mismatch.
function AssertDevice¶
void AssertDevice(
const Tensor & t,
const std::string & expected_device,
const char * file,
int line
)
Parameters:
- t The tensor to inspect.
- expected_device The expected device name.
- file Source file, supplied by the assertion macro.
- line Source line, supplied by the assertion macro.
- t Tensor to test.
- expected_device Device name to require.
- file Source file reported in the failure message.
- line Source line reported in the failure message.
Asserts that a tensor resides on expected_device, throwing on mismatch. Assert that t resides on the requested expected_device (cpu, cuda, or gpu).
function AssertClose¶
void AssertClose(
const Tensor & actual,
const Tensor & expected,
double rtol,
double atol,
const char * file,
int line
)
Parameters:
- actual The computed tensor.
- expected The reference tensor.
- rtol Relative tolerance.
- atol Absolute tolerance.
- file Source file, supplied by the assertion macro.
- line Source line, supplied by the assertion macro.
- actual Computed tensor.
- expected Reference tensor.
- rtol Relative tolerance.
- atol Absolute tolerance.
- file Source file reported in the failure message.
- line Source line reported in the failure message.
Asserts elementwise closeness of two tensors within tolerances, throwing on mismatch. Assert that actual matches expected elementwise within the given tolerances.
function AssertClose¶
Parameters:
- actual The computed tensor.
- expected The reference tensor.
- file Source file, supplied by the assertion macro.
- line Source line, supplied by the assertion macro.
- actual Computed tensor.
- expected Reference tensor.
- file Source file reported in the failure message.
- line Source line reported in the failure message.
Asserts elementwise closeness of two tensors using default tolerances, throwing on mismatch. Assert elementwise closeness using default tolerances (rtol=1.0e-4, atol=1.0e-5).