| 2077 | |
| 2078 | template <typename LhsScalar, typename RhsScalar, typename SpecType> |
| 2079 | void TestSet<LhsScalar, RhsScalar, SpecType>::VerifyNonTrivial() const { |
| 2080 | if (getenv("QUICK_BENCHMARK")) { |
| 2081 | return; |
| 2082 | } |
| 2083 | if (results.front()->path != Path::kReference) { |
| 2084 | return; |
| 2085 | } |
| 2086 | Context context; |
| 2087 | context.SetRuntimeEnabledPaths(Path::kReference); |
| 2088 | const auto& dst_storage = results.front()->storage_matrix; |
| 2089 | const Matrix<DstScalar>& dst = dst_storage.matrix; |
| 2090 | Matrix<DstScalar> unclamped_dst; |
| 2091 | unclamped_dst.layout = dst.layout; |
| 2092 | unclamped_dst.zero_point = dst.zero_point; |
| 2093 | const int size = FlatSize(unclamped_dst.layout); |
| 2094 | std::vector<DstScalar> unclamped_dst_data(size); |
| 2095 | unclamped_dst.data = unclamped_dst_data.data(); |
| 2096 | ruy::BasicSpec<AccumScalar, DstScalar> spec_unclamped; |
| 2097 | spec_unclamped.bias = spec.bias; |
| 2098 | spec_unclamped.multiplier_fixedpoint = spec.multiplier_fixedpoint; |
| 2099 | spec_unclamped.multiplier_exponent = spec.multiplier_exponent; |
| 2100 | Mul<Path::kReference>(lhs.matrix, rhs.matrix, spec_unclamped, &context, |
| 2101 | &unclamped_dst); |
| 2102 | int count_clamped = 0; |
| 2103 | bool found_distinct_values = false; |
| 2104 | for (int row = 0; row < dst.layout.rows; row++) { |
| 2105 | for (int col = 0; col < dst.layout.cols; col++) { |
| 2106 | count_clamped += |
| 2107 | (Element(dst, row, col) != Element(unclamped_dst, row, col)); |
| 2108 | found_distinct_values |= (Element(dst, row, col) != Element(dst, 0, 0)); |
| 2109 | } |
| 2110 | } |
| 2111 | if (!spec.multiplier_exponent_perchannel) { |
| 2112 | RUY_CHECK_LE(count_clamped, std::floor(2 * kClampRatio * size)); |
| 2113 | if (size > 10) { |
| 2114 | RUY_CHECK(found_distinct_values); |
| 2115 | } |
| 2116 | } |
| 2117 | } |
| 2118 | |
| 2119 | template <typename LhsScalar, typename RhsScalar, typename SpecType> |
| 2120 | void TestSet<LhsScalar, RhsScalar, SpecType>::Verify() { |