mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Replace calls to numext::fma with numext:madd.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
52f570a409
commit
2e8cc042a1
@@ -44,16 +44,16 @@ template <typename Scalar>
|
||||
struct madd_impl<Scalar,
|
||||
std::enable_if_t<Eigen::internal::is_scalar<Scalar>::value && Eigen::NumTraits<Scalar>::IsSigned>> {
|
||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar madd(const Scalar& a, const Scalar& b, const Scalar& c) {
|
||||
return numext::fma(a, b, c);
|
||||
return numext::madd(a, b, c);
|
||||
}
|
||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar msub(const Scalar& a, const Scalar& b, const Scalar& c) {
|
||||
return numext::fma(a, b, Scalar(-c));
|
||||
return numext::madd(a, b, Scalar(-c));
|
||||
}
|
||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar nmadd(const Scalar& a, const Scalar& b, const Scalar& c) {
|
||||
return numext::fma(Scalar(-a), b, c);
|
||||
return numext::madd(Scalar(-a), b, c);
|
||||
}
|
||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar nmsub(const Scalar& a, const Scalar& b, const Scalar& c) {
|
||||
return -Scalar(numext::fma(a, b, c));
|
||||
return -Scalar(numext::madd(a, b, c));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ 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);
|
||||
out = Eigen::numext::madd(v1[i], v2[i], out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -254,8 +254,6 @@ void product(const MatrixType& m) {
|
||||
// inner product
|
||||
{
|
||||
Scalar x = square2.row(c) * square2.col(c2);
|
||||
// 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user