44 template <
typename Expr1,
typename Expr2>
54 return approx_equal_contiguous(lhs, rhs, tolerance);
59 return approx_equal_logical(lhs, rhs, tolerance);
74 template <
typename Expr1,
typename Expr2>
80 using ExprPadPolicy =
typename Expr1::Layout::PadPolicyType;
82 static constexpr my_size_t lastDim = ExprPadPolicy::LastDim;
83 static constexpr my_size_t paddedLastDim = ExprPadPolicy::PaddedLastDim;
84 static constexpr my_size_t numSlices = ExprPadPolicy::PhysicalSize / paddedLastDim;
88 if constexpr (simdSteps > 0)
90 for (
my_size_t slice = 0; slice < numSlices; ++slice)
92 const my_size_t base = slice * paddedLastDim;
95 auto lhs_vec = lhs.template evalu<T, Bits, Arch>(base + i *
simdWidth);
96 auto rhs_vec = rhs.template evalu<T, Bits, Arch>(base + i *
simdWidth);
97 if (!K::all_within_tolerance(lhs_vec, rhs_vec, tolerance))
103 if constexpr (scalarStart < lastDim)
106 for (
my_size_t slice = 0; slice < numSlices; ++slice)
108 const my_size_t base = slice * paddedLastDim;
109 for (
my_size_t i = scalarStart; i < lastDim; ++i)
111 T lhs_val = lhs.template evalu<T, 1, GENERICARCH>(base + i);
112 T rhs_val = rhs.template evalu<T, 1, GENERICARCH>(base + i);
113 if (ScalarK::abs(lhs_val - rhs_val) > tolerance)
141 template <
typename Expr1,
typename Expr2>
145 T tolerance)
noexcept
150 static constexpr my_size_t logicalSize = Expr1::TotalSize;
154 for (
my_size_t i = 0; i < logicalSize; ++i)
156 T lhs_val = lhs.template logical_evalu<T, 1, GENERICARCH>(i);
157 T rhs_val = rhs.template logical_evalu<T, 1, GENERICARCH>(i);
158 if (ScalarK::abs(lhs_val - rhs_val) > tolerance)
static FORCE_INLINE bool reduce_all_approx_equal(const Expr1 &lhs, const Expr2 &rhs, T tolerance) noexcept
Check if all logical elements of two expressions are approximately equal.
Definition kernel_compare.h:45