1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | * or more contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. The ASF licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | |
20 | /*! |
21 | * \file tvm/target/codegen.h |
22 | * \brief Translates IRModule to runtime::Module. |
23 | */ |
24 | #ifndef TVM_TARGET_CODEGEN_H_ |
25 | #define TVM_TARGET_CODEGEN_H_ |
26 | |
27 | #include <tvm/ir/module.h> |
28 | #include <tvm/runtime/packed_func.h> |
29 | #include <tvm/target/target.h> |
30 | #include <tvm/tir/expr.h> |
31 | |
32 | #include <string> |
33 | |
34 | namespace tvm { |
35 | /*! \brief namespace for target translation and codegen. */ |
36 | namespace codegen { |
37 | // use packed function from runtime. |
38 | using runtime::PackedFunc; |
39 | using runtime::TVMArgs; |
40 | using runtime::TVMRetValue; |
41 | |
42 | /*! |
43 | * \brief Build a module from array of lowered function. |
44 | * \param mod The Module to be built |
45 | * \param target The target to be built. |
46 | * \return The result runtime::Module. |
47 | */ |
48 | runtime::Module Build(IRModule mod, Target target); |
49 | |
50 | /*! |
51 | * \brief Pack imported device library to a C file. |
52 | * Compile the C file and link with the host library |
53 | * will allow the DSO loader to automatically discover and import |
54 | * the dependency from the shared library. |
55 | * |
56 | * \param m The host module with the imports. |
57 | * \param system_lib Whether expose as system library. |
58 | * \return cstr The C string representation of the file. |
59 | */ |
60 | std::string PackImportsToC(const runtime::Module& m, bool system_lib); |
61 | |
62 | /*! |
63 | * \brief Pack imported device library to a LLVM module. |
64 | * Compile the LLVM module and link with the host library |
65 | * will allow the DSO loader to automatically discover and import |
66 | * the dependency from the shared library. |
67 | * |
68 | * \param m The host module with the imports. |
69 | * \param system_lib Whether expose as system library. |
70 | * \param target_triple LLVM target triple |
71 | * \return runtime::Module The generated LLVM module. |
72 | */ |
73 | runtime::Module PackImportsToLLVM(const runtime::Module& m, bool system_lib, |
74 | const std::string& target_triple); |
75 | } // namespace codegen |
76 | } // namespace tvm |
77 | #endif // TVM_TARGET_CODEGEN_H_ |
78 | |