| 110 | |
| 111 | template <typename T> |
| 112 | bool compareVar(VARP var, std::string name) { |
| 113 | auto targetValue = createVar(name, var->getInfo()->dim, var->getInfo()->type); |
| 114 | auto absMax = _ReduceMax(_Abs(targetValue), {}); |
| 115 | absMax = _Maximum(absMax, _Scalar<T>(0)); |
| 116 | auto diff = _Abs(targetValue - var); |
| 117 | auto diffAbsMax = _ReduceMax(diff); |
| 118 | auto absMaxV = absMax->readMap<T>()[0]; |
| 119 | auto diffAbsMaxV = diffAbsMax->readMap<T>()[0]; |
| 120 | // The implemention of isnan in VS2017 isn't accept integer type, so cast all type to double |
| 121 | #ifdef _MSC_VER |
| 122 | #define ALI_ISNAN(x) std::isnan(static_cast<long double>(x)) |
| 123 | #else |
| 124 | #define ALI_ISNAN(x) std::isnan(x) |
| 125 | #endif |
| 126 | if (absMaxV * 0.01f < diffAbsMaxV || ALI_ISNAN(absMaxV)) { |
| 127 | std::cout << "TESTERROR " << name << " value error : absMaxV:" << absMaxV << " - DiffMax:" << diffAbsMaxV << std::endl; |
| 128 | return false; |
| 129 | } |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | void log_result(bool correct) { |
| 134 | if (correct) { |
nothing calls this directly
no test coverage detected