6 #ifndef TREELITE_COMPILER_AST_BUILDER_H_ 7 #define TREELITE_COMPILER_AST_BUILDER_H_ 23 struct CodeFoldingContext;
24 bool fold_code(ASTNode*, CodeFoldingContext*, ASTBuilder*);
25 bool breakup(ASTNode*,
int,
int*, ASTBuilder*);
29 ASTBuilder() : output_vector_flag(
false), main_node(
nullptr),
30 quantize_threshold_flag(
false) {}
33 void BuildAST(
const Model& model);
36 std::vector<bool> GenerateIsCategoricalArray();
51 bool FoldCode(
double magnitude_req,
bool create_new_translation_unit =
false);
56 void Split(
int parallel_comp);
58 void QuantizeThresholds();
60 void LoadDataCounts(
const std::vector<std::vector<size_t>>& counts);
64 std::string GetDump()
const;
66 inline const ASTNode* GetRootNode() {
74 template <
typename NodeType,
typename ...Args>
75 NodeType* AddNode(
ASTNode* parent, Args&& ...args) {
76 std::unique_ptr<NodeType> node(
new NodeType(std::forward<Args>(args)...));
77 NodeType* ref = node.get();
79 nodes.push_back(std::move(node));
83 ASTNode* BuildASTFromTree(
const Tree& tree,
int tree_id,
int nid,
87 std::vector<std::unique_ptr<ASTNode>> nodes;
88 bool output_vector_flag;
89 bool quantize_threshold_flag;
92 bool random_forest_flag;
94 std::vector<bool> is_categorical;
95 std::map<std::string, std::string> model_param;
101 #endif // TREELITE_COMPILER_AST_BUILDER_H_ thin wrapper for tree ensemble model
model structure for tree ensemble
Definition for AST classes.
in-memory representation of a decision tree