DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
ProtoDUNEBSMWindow
CompiledModelInterface.cpp
Go to the documentation of this file.
1
#include "
triggeralgs/ProtoDUNEBSMWindow/CompiledModelInterface.hpp
"
2
3
#include <iostream>
4
5
namespace
triggeralgs
{
6
7
CompiledModelInterface::CompiledModelInterface
(
int
nbatch) : num_batch(nbatch) {
8
model_ptr
= std::make_unique<TreelitePDHDModel>();
9
}
10
11
CompiledModelInterface::~CompiledModelInterface
() {}
12
13
int
CompiledModelInterface::GetNumFeatures
() {
14
return
model_ptr
->get_num_feature();
15
}
16
17
void
CompiledModelInterface::ModelWarmUp
(
Entry
*input) {
18
// Warm the BDT up here
19
float
result[
num_batch
];
20
for
(
int
rid = 0; rid <
num_batch
; ++rid) {
21
for
(
int
i = 0; i < 100; i++) {
22
model_ptr
->predict(input, 0, result);
23
}
24
}
25
}
26
27
void
CompiledModelInterface::Predict
(
Entry
*input,
float
*result) {
28
for
(
int
rid = 0; rid <
num_batch
; ++rid) {
29
model_ptr
->predict(input, 0, result);
30
}
31
}
32
33
bool
CompiledModelInterface::Classify
(
const
float
*result,
float
&bdt_threshold) {
34
for
(uint64_t rid = 0; rid <
num_batch
; rid++) {
35
if
(result[rid] > bdt_threshold) {
36
return
true
;
37
}
38
}
39
return
false
;
40
}
41
42
43
}
// namespace triggeralgs
CompiledModelInterface.hpp
triggeralgs::CompiledModelInterface::Classify
bool Classify(const float *result, float &bdt_threshold)
Definition
CompiledModelInterface.cpp:33
triggeralgs::CompiledModelInterface::Predict
void Predict(Entry *input, float *result)
Definition
CompiledModelInterface.cpp:27
triggeralgs::CompiledModelInterface::GetNumFeatures
int GetNumFeatures()
Definition
CompiledModelInterface.cpp:13
triggeralgs::CompiledModelInterface::num_batch
int num_batch
Definition
CompiledModelInterface.hpp:38
triggeralgs::CompiledModelInterface::model_ptr
std::unique_ptr< TreeliteModelBase > model_ptr
Definition
CompiledModelInterface.hpp:37
triggeralgs::CompiledModelInterface::ModelWarmUp
void ModelWarmUp(Entry *input)
Definition
CompiledModelInterface.cpp:17
triggeralgs::CompiledModelInterface::CompiledModelInterface
CompiledModelInterface(int nbatch)
Definition
CompiledModelInterface.cpp:7
triggeralgs::CompiledModelInterface::~CompiledModelInterface
~CompiledModelInterface()
Definition
CompiledModelInterface.cpp:11
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::Entry
Definition
treelitemodel.hpp:20
Generated on Sat Apr 4 2026 for DUNE-DAQ by
1.12.0