mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Reduce flakiness of test for Eigen::half.
This commit is contained in:
@@ -38,6 +38,15 @@ template <typename LhsType, typename RhsType>
|
||||
std::enable_if_t<RhsType::SizeAtCompileTime != Dynamic, void> check_mismatched_product(LhsType& /*unused*/,
|
||||
const RhsType& /*unused*/) {}
|
||||
|
||||
template <typename Scalar, typename V1, typename V2>
|
||||
Scalar ref_dot_product(const V1& v1, const V2& v2) {
|
||||
Scalar out = Scalar(0);
|
||||
for (Index i = 0; i < v1.size(); ++i) {
|
||||
out = Eigen::numext::fma(v1[i], v2[i], out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void product(const MatrixType& m) {
|
||||
/* this test covers the following files:
|
||||
@@ -245,7 +254,10 @@ void product(const MatrixType& m) {
|
||||
// inner product
|
||||
{
|
||||
Scalar x = square2.row(c) * square2.col(c2);
|
||||
VERIFY_IS_APPROX(x, square2.row(c).transpose().cwiseProduct(square2.col(c2)).sum());
|
||||
// NOTE: FMA is necessary here in the reference to ensure accuracy for
|
||||
// large vector sizes and float16/bfloat16 types.
|
||||
Scalar y = ref_dot_product<Scalar>(square2.row(c), square2.col(c2));
|
||||
VERIFY_IS_APPROX(x, y);
|
||||
}
|
||||
|
||||
// outer product
|
||||
|
||||
Reference in New Issue
Block a user