fix tests when scalar is bfloat16, half

This commit is contained in:
Charles Schlosser 2024-02-07 04:50:11 +00:00 committed by Antonio Sánchez
parent 3ebaab8a63
commit 3ab8f48256
4 changed files with 5 additions and 5 deletions

View File

@ -26,7 +26,7 @@ void array_for_matrix(const MatrixType& m) {
// Prevent overflows for integer types.
if (Eigen::NumTraits<Scalar>::IsInteger) {
constexpr Scalar kMaxVal = Scalar(10000);
Scalar kMaxVal = Scalar(10000);
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
}

View File

@ -72,7 +72,7 @@ void product(const MatrixType& m) {
// Prevent overflows for integer types.
if (Eigen::NumTraits<Scalar>::IsInteger) {
constexpr Scalar kMaxVal = Scalar(10000);
Scalar kMaxVal = Scalar(10000);
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
v1.array() = v1.array() - kMaxVal * (v1.array() / kMaxVal);

View File

@ -24,7 +24,7 @@ void matrixRedux(const MatrixType& m) {
MatrixType m1 = MatrixType::Random(rows, cols);
// The entries of m1 are uniformly distributed in [0,1], so m1.prod() is very small. This may lead to test
// The entries of m1 are uniformly distributed in [-1,1), so m1.prod() is very small. This may lead to test
// failures if we underflow into denormals. Thus, we scale so that entries are close to 1.
MatrixType m1_for_prod = MatrixType::Ones(rows, cols) + RealScalar(0.2) * m1;
@ -32,7 +32,7 @@ void matrixRedux(const MatrixType& m) {
m2.setRandom();
// Prevent overflows for integer types.
if (Eigen::NumTraits<Scalar>::IsInteger) {
constexpr Scalar kMaxVal = Scalar(10000);
Scalar kMaxVal = Scalar(10000);
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
}

View File

@ -466,7 +466,7 @@ void test_stl_iterators(int rows = Rows, int cols = Cols) {
VectorType col = VectorType::Random(rows);
// Prevent overflows for integer types.
if (Eigen::NumTraits<Scalar>::IsInteger) {
constexpr Scalar kMaxVal = Scalar(1000);
Scalar kMaxVal = Scalar(1000);
row.array() = row.array() - kMaxVal * (row.array() / kMaxVal);
col.array() = col.array() - kMaxVal * (col.array() / kMaxVal);
}