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

Function act_dump_record

engine/src/kernels/cpu/native_expert.cpp:488–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486 }
487}
488void act_dump_record(int layer, int kind, const float* v, int64_t n) {
489 ActDump& d = act_dump();
490 if (std::find(d.layers.begin(), d.layers.end(), layer) == d.layers.end()) return;
491 std::lock_guard<std::mutex> lk(d.mu);
492 ActAcc& a = d.acc[{layer, kind}];
493 if (a.n == 0) {
494 a.n = n;
495 a.sq.assign((size_t) n, 0.0);
496 if (d.cov) a.cov.assign((size_t) n * (size_t) n, 0.0);
497 }
498 for (int64_t i = 0; i < n; ++i) a.sq[(size_t) i] += (double) v[i] * v[i];
499 if (d.cov)
500 for (int64_t i = 0; i < n; ++i) {
501 double* row = a.cov.data() + (size_t) i * (size_t) n;
502 const double vi = v[i];
503 for (int64_t j = 0; j < n; ++j) row[j] += vi * v[j];
504 }
505 ++a.count;
506 if (++d.records % (d.cov ? 400000 : 2000) == 0) {
507 d.mu.unlock();
508 ActDump::act_dump_flush();
509 d.mu.lock();
510 }
511}
512} // namespace
513
514void native_quant_act(const NativeFmt& f, const float* x, void* dst) {

Callers 2

native_quant_actFunction · 0.85
native_quant_hFunction · 0.85

Calls 6

assignMethod · 0.80
unlockMethod · 0.80
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected