mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-31 10:34:02 +08:00
fix tests when scalar is bfloat16, half
This commit is contained in:
parent
3ebaab8a63
commit
3ab8f48256
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user