| 242 | }; |
| 243 | |
| 244 | CompareResult compareUnorm8(const char* rawLhs, const char* rawRhs, std::size_t rawSize, float tolerance) { |
| 245 | const auto* lhs = reinterpret_cast<const uint8_t*>(rawLhs); |
| 246 | const auto* rhs = reinterpret_cast<const uint8_t*>(rawRhs); |
| 247 | const auto element_size = sizeof(uint8_t); |
| 248 | const auto count = rawSize / element_size; |
| 249 | |
| 250 | for (std::size_t i = 0; i < count; ++i) { |
| 251 | const auto diff = std::abs(static_cast<float>(lhs[i]) / 255.f - static_cast<float>(rhs[i]) / 255.f); |
| 252 | if (diff > tolerance) |
| 253 | return CompareResult{false, diff, i, i * element_size}; |
| 254 | } |
| 255 | |
| 256 | return CompareResult{}; |
| 257 | } |
| 258 | |
| 259 | CompareResult compareSFloat32(const char* rawLhs, const char* rawRhs, std::size_t rawSize, float tolerance) { |
| 260 | const auto* lhs = reinterpret_cast<const float*>(rawLhs); |
no test coverage detected