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