DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
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,
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
15
CompiledModelInterface::~CompiledModelInterface
() {}
16
17
int
CompiledModelInterface::GetNumFeatures
() {
18
return
model_ptr
->get_num_feature();
19
}
20
21
void
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
27
bool
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
CompiledModelInterface.hpp
triggeralgs::CompiledModelInterface::Predict
void Predict(Entry *input, float *result)
Definition
CompiledModelInterface.cpp:21
triggeralgs::CompiledModelInterface::GetNumFeatures
int GetNumFeatures()
Definition
CompiledModelInterface.cpp:17
triggeralgs::CompiledModelInterface::num_batch
int num_batch
Definition
CompiledModelInterface.hpp:36
triggeralgs::CompiledModelInterface::model_ptr
std::unique_ptr< TreeliteModelBase > model_ptr
Definition
CompiledModelInterface.hpp:35
triggeralgs::CompiledModelInterface::Classify
bool Classify(const float *result, float bdt_threshold)
Definition
CompiledModelInterface.cpp:27
triggeralgs::CompiledModelInterface::CompiledModelInterface
CompiledModelInterface(int nbatch, bool is_pdvd)
Definition
CompiledModelInterface.cpp:7
triggeralgs::CompiledModelInterface::~CompiledModelInterface
~CompiledModelInterface()
Definition
CompiledModelInterface.cpp:15
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::Entry
Definition
treelitemodel.hpp:20
Generated on
for DUNE-DAQ by
1.17.0