codegen.h 1.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*!
 *  Copyright (c) 2016 by Contributors
 * \file codegen.h
 * \brief Collection of Lowlevel IR pass to codegen.
 */
#ifndef TVM_CODEGEN_H_
#define TVM_CODEGEN_H_

#include <string>
#include "./base.h"
#include "./expr.h"
12
#include "./lowered_func.h"
13
#include "./api_registry.h"
14
#include "./runtime/packed_func.h"
15

16 17 18
namespace tvm {
/*! \brief namespace for lowlevel IR pass and codegen */
namespace codegen {
19 20 21 22 23
// use packed function from runtime.
using runtime::PackedFunc;
using runtime::TVMArgs;
using runtime::TVMRetValue;

24
/*!
25 26 27 28
 * \brief Build a module from array of lowered function.
 * \param funcs The functions to be built.
 * \param target The target to be built.
 * \return The builded module.
29
 *
30
 * \note Calls global API function  "_codegen_build_" + target
31
 */
32 33
runtime::Module Build(const Array<LoweredFunc>& funcs,
                      const std::string& target);
34 35 36 37 38 39 40
/*!
 * \brief Pack imported device library to a C file.
 *  Compile the C file and link with the host library
 *  will allow the DSO loader to automatically discover and import
 *  the dependency from the shared library.
 *
 * \param m The host module with the imports.
41
 * \param system_lib Whether expose as system library.
42 43
 * \return cstr The C string representation of the file.
 */
44
std::string PackImportsToC(const runtime::Module& m, bool system_lib);
45 46 47 48
}  // namespace codegen
}  // namespace tvm

#endif  // TVM_CODEGEN_H_