DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CompiledModelInterface.cpp
Go to the documentation of this file.
2
3#include <iostream>
4
5namespace triggeralgs {
6
7CompiledModelInterface::CompiledModelInterface(int nbatch, bool is_pdvd) : num_batch(nbatch) {
8 if (is_pdvd) {
9 model_ptr = std::make_unique<TreelitePDVDModel>();
10 } else {
11 model_ptr = std::make_unique<TreelitePDHDModel>();
12 }
13}
14
16
18 return model_ptr->get_num_feature();
19}
20
21void CompiledModelInterface::Predict(Entry *input, float *result) {
22 for (int rid = 0; rid < num_batch; ++rid) {
23 model_ptr->predict(input, 0, result);
24 }
25}
26
27bool CompiledModelInterface::Classify(const float *result, float bdt_threshold) {
28 for (uint64_t rid = 0; rid < num_batch; rid++) {
29 if (result[rid] > bdt_threshold) {
30 return true;
31 }
32 }
33 return false;
34}
35
36
37} // namespace triggeralgs
void Predict(Entry *input, float *result)
std::unique_ptr< TreeliteModelBase > model_ptr
bool Classify(const float *result, float bdt_threshold)
CompiledModelInterface(int nbatch, bool is_pdvd)