add extra debugging info to float_pow_test_impl, clean up array_cwise tests

This commit is contained in:
Charles Schlosser
2024-09-24 21:08:22 +00:00
parent ba5183f98c
commit d052b7f864
2 changed files with 55 additions and 69 deletions

View File

@@ -65,7 +65,7 @@ std::vector<Scalar> special_values() {
template <typename Scalar>
void special_value_pairs(Array<Scalar, Dynamic, Dynamic>& x, Array<Scalar, Dynamic, Dynamic>& y) {
std::vector<Scalar> vals = special_values<Scalar>();
int num_cases = vals.size() * vals.size();
std::size_t num_cases = vals.size() * vals.size();
// ensure both vectorized and non-vectorized paths taken
const Index num_repeats = 2 * (Index)internal::packet_traits<Scalar>::size + 1;
x.resize(num_repeats, num_cases);
@@ -294,6 +294,7 @@ void float_pow_test_impl() {
bool success = both_nan || (exact_or_approx && same_sign);
all_pass &= success;
if (!success) {
std::cout << "Base type: " << type_name(base) << ", Exponent type: " << type_name(exponent) << std::endl;
std::cout << "pow(" << bases(j) << "," << exponent << ") = " << a << " != " << e << std::endl;
}
}
@@ -1250,61 +1251,6 @@ void typed_logicals_test(const ArrayType& m) {
typed_logicals_test_impl<ArrayType>::run(m);
}
// print non-mangled typenames
template <typename T>
std::string printTypeInfo(const T&) {
return typeid(T).name();
}
template <>
std::string printTypeInfo(const int8_t&) {
return "int8_t";
}
template <>
std::string printTypeInfo(const int16_t&) {
return "int16_t";
}
template <>
std::string printTypeInfo(const int32_t&) {
return "int32_t";
}
template <>
std::string printTypeInfo(const int64_t&) {
return "int64_t";
}
template <>
std::string printTypeInfo(const uint8_t&) {
return "uint8_t";
}
template <>
std::string printTypeInfo(const uint16_t&) {
return "uint16_t";
}
template <>
std::string printTypeInfo(const uint32_t&) {
return "uint32_t";
}
template <>
std::string printTypeInfo(const uint64_t&) {
return "uint64_t";
}
template <>
std::string printTypeInfo(const float&) {
return "float";
}
template <>
std::string printTypeInfo(const double&) {
return "double";
}
// template<> std::string printTypeInfo(const long double&) { return "long double"; }
template <>
std::string printTypeInfo(const half&) {
return "half";
}
template <>
std::string printTypeInfo(const bfloat16&) {
return "bfloat16";
}
template <typename SrcType, typename DstType, int RowsAtCompileTime, int ColsAtCompileTime>
struct cast_test_impl {
using SrcArray = Array<SrcType, RowsAtCompileTime, ColsAtCompileTime>;
@@ -1340,8 +1286,8 @@ struct cast_test_impl {
DstType dstVal = dst(i, j);
bool isApprox = verifyIsApprox(dstVal, refVal);
if (!isApprox)
std::cout << printTypeInfo(srcVal) << ": [" << +srcVal << "] to " << printTypeInfo(dstVal) << ": ["
<< +dstVal << "] != [" << +refVal << "]\n";
std::cout << type_name(srcVal) << ": [" << +srcVal << "] to " << type_name(dstVal) << ": [" << +dstVal
<< "] != [" << +refVal << "]\n";
VERIFY(isApprox);
}
}