treelite
compiler.h
Go to the documentation of this file.
1 
7 #ifndef TREELITE_COMPILER_H_
8 #define TREELITE_COMPILER_H_
9 
10 #include <dmlc/registry.h>
11 #include <treelite/common.h>
12 #include <unordered_map>
13 #include <functional>
14 #include <memory>
15 #include <string>
16 
17 namespace treelite {
18 
19 struct Model; // forward declaration
20 
21 namespace compiler {
22 
23 struct CompilerParam; // forward declaration
24 
25 struct CompiledModel {
26  std::string backend;
27  std::unordered_map<std::string, std::string> files;
28  std::string file_prefix;
29 };
30 
31 } // namespace compiler
32 
34 class Compiler {
35  public:
37  virtual ~Compiler() = default;
42  virtual compiler::CompiledModel Compile(const Model& model) = 0;
48  static Compiler* Create(const std::string& name,
49  const compiler::CompilerParam& param);
50 };
51 
56  : public dmlc::FunctionRegEntryBase<CompilerReg,
57  std::function<Compiler* (const compiler::CompilerParam&)> > {
58 };
59 
72 #define TREELITE_REGISTER_COMPILER(UniqueId, Name) \
73  static DMLC_ATTRIBUTE_UNUSED ::treelite::CompilerReg & \
74  __make_ ## CompilerReg ## _ ## UniqueId ## __ = \
75  ::dmlc::Registry< ::treelite::CompilerReg>::Get()->__REGISTER__(Name)
76 
77 } // namespace treelite
78 
79 #endif // TREELITE_COMPILER_H_
thin wrapper for tree ensemble model
Definition: tree.h:428
parameters for tree compiler
Definition: param.h:18
interface of compiler
Definition: compiler.h:34
Registry entry for compiler.
Definition: compiler.h:55