Treelite
load_data_counts.cc
Go to the documentation of this file.
1 
7 #include <dmlc/registry.h>
8 #include <cmath>
9 #include "./builder.h"
10 
11 namespace treelite {
12 namespace compiler {
13 
14 DMLC_REGISTRY_FILE_TAG(load_data_counts);
15 
16 static void load_data_counts(ASTNode* node,
17  const std::vector<std::vector<size_t>>& counts) {
18  if (node->tree_id >= 0 && node->node_id >= 0) {
19  node->data_count = counts[node->tree_id][node->node_id];
20  }
21  for (ASTNode* child : node->children) {
22  load_data_counts(child, counts);
23  }
24 }
25 
26 void
27 ASTBuilder::LoadDataCounts(const std::vector<std::vector<size_t>>& counts) {
28  load_data_counts(this->main_node, counts);
29 }
30 
31 } // namespace compiler
32 } // namespace treelite
AST Builder class.