MCPcopy Create free account
hub / github.com/Niko1221/Strata / check_act

Function check_act

engine/src/quant/selfcheck.cpp:136–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136bool 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
161struct Verdicts {

Callers 2

selfcheckFunction · 0.85
checked_act_kernelFunction · 0.85

Calls 6

generic_act_tableFunction · 0.85
type_infoFunction · 0.70
stringFunction · 0.50
nextMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected