Treelite
dump.cc
Go to the documentation of this file.
1 
6 #include <dmlc/registry.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  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 DMLC_REGISTRY_FILE_TAG(dump);
27 
28 template <typename ThresholdType, typename LeafOutputType>
29 std::string
30 ASTBuilder<ThresholdType, LeafOutputType>::GetDump() const {
31  std::ostringstream oss;
32  get_dump_from_node(&oss, this->main_node, 0);
33  return oss.str();
34 }
35 
36 template std::string ASTBuilder<float, uint32_t>::GetDump() const;
37 template std::string ASTBuilder<float, float>::GetDump() const;
38 template std::string ASTBuilder<double, uint32_t>::GetDump() const;
39 template std::string ASTBuilder<double, double>::GetDump() const;
40 
41 } // namespace compiler
42 } // namespace treelite
AST Builder class.