Treelite
src
compiler
native
code_folder_template.h
Go to the documentation of this file.
1
8
#ifndef TREELITE_COMPILER_NATIVE_CODE_FOLDER_TEMPLATE_H_
9
#define TREELITE_COMPILER_NATIVE_CODE_FOLDER_TEMPLATE_H_
10
11
namespace
treelite
{
12
namespace
compiler {
13
namespace
native {
14
15
const
char
*
const
eval_loop_template =
16
R
"TREELITETEMPLATE(
17
nid = 0;
18
while (nid >= 0) {{ /* negative nid implies leaf */
19
fid = {node_array_name}[nid].split_index;
20
if (data[fid].missing == -1) {{
21
cond = {node_array_name}[nid].default_left;
22
}} else if (is_categorical[fid]) {{
23
tmp = (unsigned int)data[fid].fvalue;
24
cond = ({cat_bitmap_name}[{cat_begin_name}[nid] + tmp / 64] >> (tmp % 64)) & 1;
25
}} else {{
26
cond = (data[fid].{data_field} {comp_op} {node_array_name}[nid].threshold);
27
}}
28
nid = cond ? {node_array_name}[nid].left_child : {node_array_name}[nid].right_child;
29
}}
30
31
{output_switch_statement}
32
)TREELITETEMPLATE";
33
34
const
char
*
const
eval_loop_template_without_categorical_feature =
35
R
"TREELITETEMPLATE(
36
nid = 0;
37
while (nid >= 0) {{ /* negative nid implies leaf */
38
fid = {node_array_name}[nid].split_index;
39
if (data[fid].missing == -1) {{
40
cond = {node_array_name}[nid].default_left;
41
}} else {{
42
cond = (data[fid].{data_field} {comp_op} {node_array_name}[nid].threshold);
43
}}
44
nid = cond ? {node_array_name}[nid].left_child : {node_array_name}[nid].right_child;
45
}}
46
47
{output_switch_statement}
48
)TREELITETEMPLATE";
49
50
}
// namespace native
51
}
// namespace compiler
52
}
// namespace treelite
53
#endif // TREELITE_COMPILER_NATIVE_CODE_FOLDER_TEMPLATE_H_
treelite
Definition:
annotator.h:18
Generated by
1.8.13