mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Merge latest changes from upstream
This commit is contained in:
@@ -21,6 +21,17 @@ include_directories(../../test ../../unsupported ../../Eigen
|
||||
|
||||
find_package (Threads)
|
||||
|
||||
find_package(Xsmm)
|
||||
if(XSMM_FOUND)
|
||||
add_definitions("-DEIGEN_USE_LIBXSMM")
|
||||
include_directories(${XSMM_INCLUDES})
|
||||
link_directories(${XSMM_LIBRARIES})
|
||||
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} xsmm)
|
||||
ei_add_property(EIGEN_TESTED_BACKENDS "Xsmm, ")
|
||||
else(XSMM_FOUND)
|
||||
ei_add_property(EIGEN_MISSING_BACKENDS "Xsmm, ")
|
||||
endif(XSMM_FOUND)
|
||||
|
||||
find_package(GoogleHash)
|
||||
if(GOOGLEHASH_FOUND)
|
||||
add_definitions("-DEIGEN_GOOGLEHASH_SUPPORT")
|
||||
|
||||
@@ -300,6 +300,51 @@ static void test_select()
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Scalar>
|
||||
void test_minmax_nan_propagation_templ() {
|
||||
for (int size = 1; size < 17; ++size) {
|
||||
const Scalar kNan = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
Tensor<Scalar, 1> vec_nan(size);
|
||||
Tensor<Scalar, 1> vec_zero(size);
|
||||
Tensor<Scalar, 1> vec_res(size);
|
||||
vec_nan.setConstant(kNan);
|
||||
vec_zero.setZero();
|
||||
vec_res.setZero();
|
||||
|
||||
// Test that we propagate NaNs in the tensor when applying the
|
||||
// cwiseMax(scalar) operator, which is used for the Relu operator.
|
||||
vec_res = vec_nan.cwiseMax(Scalar(0));
|
||||
for (int i = 0; i < size; ++i) {
|
||||
VERIFY((numext::isnan)(vec_res(i)));
|
||||
}
|
||||
|
||||
// Test that NaNs do not propagate if we reverse the arguments.
|
||||
vec_res = vec_zero.cwiseMax(kNan);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
VERIFY_IS_EQUAL(vec_res(i), Scalar(0));
|
||||
}
|
||||
|
||||
// Test that we propagate NaNs in the tensor when applying the
|
||||
// cwiseMin(scalar) operator.
|
||||
vec_res.setZero();
|
||||
vec_res = vec_nan.cwiseMin(Scalar(0));
|
||||
for (int i = 0; i < size; ++i) {
|
||||
VERIFY((numext::isnan)(vec_res(i)));
|
||||
}
|
||||
|
||||
// Test that NaNs do not propagate if we reverse the arguments.
|
||||
vec_res = vec_zero.cwiseMin(kNan);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
VERIFY_IS_EQUAL(vec_res(i), Scalar(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_minmax_nan_propagation()
|
||||
{
|
||||
test_minmax_nan_propagation_templ<float>();
|
||||
test_minmax_nan_propagation_templ<double>();
|
||||
}
|
||||
|
||||
void test_cxx11_tensor_expr()
|
||||
{
|
||||
@@ -311,4 +356,5 @@ void test_cxx11_tensor_expr()
|
||||
CALL_SUBTEST(test_functors());
|
||||
CALL_SUBTEST(test_type_casting());
|
||||
CALL_SUBTEST(test_select());
|
||||
CALL_SUBTEST(test_minmax_nan_propagation());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user