treelite
is_categorical_array.cc
Go to the documentation of this file.
1 
7 #include "./builder.h"
8 
9 namespace treelite {
10 namespace compiler {
11 
12 DMLC_REGISTRY_FILE_TAG(is_categorical_array);
13 
14 static void
15 scan_thresholds(ASTNode* node, std::vector<bool>* is_categorical) {
16  CategoricalConditionNode* cat_cond
17  = dynamic_cast<CategoricalConditionNode*>(node);
18  if (cat_cond) {
19  (*is_categorical)[cat_cond->split_index] = true;
20  }
21  for (ASTNode* child : node->children) {
22  scan_thresholds(child, is_categorical);
23  }
24 }
25 
26 std::vector<bool> ASTBuilder::GenerateIsCategoricalArray() {
27  this->is_categorical = std::vector<bool>(this->num_feature, false);
28  scan_thresholds(this->main_node, &this->is_categorical);
29  return this->is_categorical;
30 }
31 
32 } // namespace compiler
33 } // namespace treelite
AST Builder class.