Treelite
dump.cc
Go to the documentation of this file.
1 
6 #include <treelite/logging.h>
7 #include "./builder.h"
8 
9 namespace {
10 
11 void get_dump_from_node(std::ostringstream* oss,
12  const treelite::compiler::ASTNode* node,
13  int indent) {
14  (*oss) << std::string(indent, ' ') << node->GetDump() << "\n";
15  for (const treelite::compiler::ASTNode* child : node->children) {
16  TREELITE_CHECK(child);
17  get_dump_from_node(oss, child, indent + 2);
18  }
19 }
20 
21 } // anonymous namespace
22 
23 namespace treelite {
24 namespace compiler {
25 
26 template <typename ThresholdType, typename LeafOutputType>
27 std::string
28 ASTBuilder<ThresholdType, LeafOutputType>::GetDump() const {
29  std::ostringstream oss;
30  get_dump_from_node(&oss, this->main_node, 0);
31  return oss.str();
32 }
33 
34 template std::string ASTBuilder<float, uint32_t>::GetDump() const;
35 template std::string ASTBuilder<float, float>::GetDump() const;
36 template std::string ASTBuilder<double, uint32_t>::GetDump() const;
37 template std::string ASTBuilder<double, double>::GetDump() const;
38 
39 } // namespace compiler
40 } // namespace treelite
logging facility for Treelite
AST Builder class.