| 134 | } |
| 135 | |
| 136 | bool check_act(const ActKernel& k, std::string* why) { |
| 137 | const TypeInfo* ti = type_info(k.act); |
| 138 | if (ti == nullptr) return false; |
| 139 | const ActKernel* ref = nullptr; |
| 140 | const ActTable g = generic_act_table(); |
| 141 | for (int i = 0; i < g.n; ++i) |
| 142 | if (g.v[i].act == k.act) ref = &g.v[i]; |
| 143 | if (ref == nullptr) return false; |
| 144 | Rng r(0xAC7 + (uint64_t) k.act); |
| 145 | for (int c : {1, 2, 3, 5}) { |
| 146 | const int n = ti->blck * c; |
| 147 | std::vector<float> x((size_t) n); |
| 148 | for (float& v : x) v = (float) ((int) (r.next() % 20001) - 10000) * (1.0f / 977.0f); // arbitrary values, ties are improbable |
| 149 | std::vector<uint8_t> a((size_t) c * ti->bytes), b((size_t) c * ti->bytes); |
| 150 | ref->fn(x.data(), a.data(), n); |
| 151 | k.fn(x.data(), b.data(), n); |
| 152 | if (std::memcmp(a.data(), b.data(), a.size()) != 0) { |
| 153 | if (why) *why = std::string(k.name) + ": the blocks differ from the reference quantizer"; |
| 154 | return false; |
| 155 | } |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | // one verdict per (kind, type, arith, isa), computed on first use |
| 161 | struct Verdicts { |