Skip to main content

ClikaRT::ops::allclose

function

allclose()

Tensor allclose(
    Tensor a,
    Tensor b,
    double rtol = 1e-5,
    double atol = 1e-8,
    bool equal_nan = false
)

Whether EVERY elementwise pair is approximately equal, a reduction to one verdict.

abatol+rtolbfor every pair|a - b| \le atol + rtol \cdot |b| \quad \text{for every pair}

Shapes broadcast per the standard rules before the reduction.

Parameters

  • a, b — the tensors to compare.
  • rtol: relative tolerance; default 1e-5.
  • atol: absolute tolerance; default 1e-8.
  • equal_nan: when true, NaN compares equal to NaN; default false.

Returns: a 0-D Bool tensor; true iff every pair passes (use ops::isclose for the elementwise map).

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the operand shapes are not broadcast-compatible.

    bool same = ClikaRT::ops::allclose(y, want).item<bool>();

Declared in ClikaRT/compute/ops.h, line 1645