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 <functional>
13 #include <memory>
14 #include <string>
15 
16 namespace treelite {
17 
18 struct Model; // forward declaration
19 
20 namespace compiler {
21 
22 struct CompilerParam; // forward declaration
23 
24 struct CompiledModel {
25  std::string backend;
26  std::unordered_map<std::string, std::string> files;
27  std::string file_prefix;
28 };
29 
30 } // namespace compiler
31 
33 class Compiler {
34  public:
36  virtual ~Compiler() = default;
41  virtual compiler::CompiledModel Compile(const Model& model) = 0;
47  static Compiler* Create(const std::string& name,
48  const compiler::CompilerParam& param);
49 };
50 
55  : public dmlc::FunctionRegEntryBase<CompilerReg,
56  std::function<Compiler* (const compiler::CompilerParam&)> > {
57 };
58 
71 #define TREELITE_REGISTER_COMPILER(UniqueId, Name) \
72  static DMLC_ATTRIBUTE_UNUSED ::treelite::CompilerReg & \
73  __make_ ## CompilerReg ## _ ## UniqueId ## __ = \
74  ::dmlc::Registry< ::treelite::CompilerReg>::Get()->__REGISTER__(Name)
75 
76 } // namespace treelite
77 
78 #endif // TREELITE_COMPILER_H_
thin wrapper for tree ensemble model
Definition: tree.h:415
parameters for tree compiler
Definition: param.h:18
interface of compiler
Definition: compiler.h:33
Registry entry for compiler.
Definition: compiler.h:54