tvm
driver_api.h
Go to the documentation of this file.
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 
29 #ifndef TVM_DRIVER_DRIVER_API_H_
30 #define TVM_DRIVER_DRIVER_API_H_
31 
32 #include <tvm/ir/module.h>
33 #include <tvm/ir/transform.h>
35 #include <tvm/support/with.h>
36 #include <tvm/target/target.h>
37 #include <tvm/te/schedule_pass.h>
38 #include <tvm/tir/function.h>
39 
40 #include <string>
41 #include <unordered_map>
42 #include <unordered_set>
43 #include <utility>
44 #include <vector>
45 
46 namespace tvm {
48 
56 TVM_DLL transform::Sequential MixedModulePassManager(IRModule mixed_mod, Target target);
57 
65 TVM_DLL transform::Sequential DeviceModulePassManager(IRModule mixed_mod, Target target);
66 
74 TVM_DLL transform::Sequential HostModulePassManager(IRModule mixed_mod, Target target_host);
75 
82 TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false);
83 
92 TVM_DLL IRModule LowerPrimFunc(tvm::tir::PrimFunc func, const std::string& name,
93  bool simple_mode = false);
94 
106 TVM_DLL IRModule LowerSchedule(te::Schedule sch, const Array<te::Tensor>& args,
107  const std::string& name,
108  const std::unordered_map<te::Tensor, tir::Buffer>& binds,
109  bool simple_mode = false);
110 
121 TVM_DLL IRModule LowerSchedule(te::Schedule sch, const Array<ObjectRef>& args,
122  const std::string& name,
123  const std::unordered_map<te::Tensor, tir::Buffer>& binds,
124  bool simple_mode = false);
125 
135 IRModule ScheduleToModule(te::Schedule sch, const Array<ObjectRef>& args, const std::string& name,
136  const std::unordered_map<te::Tensor, tir::Buffer>& binds);
144 TVM_DLL runtime::Module build(const IRModule& funcs, const Target& target,
145  const Target& target_host);
146 
156 TVM_DLL runtime::Module build(const Map<Target, IRModule>& input, const Target& target_host);
157 
167 TVM_DLL runtime::Module build(const Map<String, IRModule>& input, const Target& target_host);
168 
169 } // namespace tvm
170 
171 #endif // TVM_DRIVER_DRIVER_API_H_
IRModule LowerModule(IRModule mod, bool simple_mode=false)
Lower an IRModule (optimize with it with the pass list defined in CreatePassList) ...
transform::Sequential MixedModulePassManager(IRModule mixed_mod, Target target)
Configures and returns the composite Pass for the fused module (pre split) that contains device and h...
IRModule that holds the functions and type definitions.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
IRModule LowerPrimFunc(tvm::tir::PrimFunc func, const std::string &name, bool simple_mode=false)
Lower a primfunc and name (convert to IRModule, and optimize it with the pass list defined in CreateP...
tvm::transform::Sequential Sequential
Definition: transform.h:49
TIR Function.
tvm::transform::Pass Pass
Definition: transform.h:43
Collection of Schedule pass functions.
Managed reference to PrimFuncNode.
Definition: function.h:156
IRModule LowerSchedule(te::Schedule sch, const Array< te::Tensor > &args, const std::string &name, const std::unordered_map< te::Tensor, tir::Buffer > &binds, bool simple_mode=false)
Build an IRModule given a TE schedule, args and binds. This function also applies the lowering passes...
transform::Sequential DeviceModulePassManager(IRModule mixed_mod, Target target)
Configures and returns the composite Pass for the device Target after device/host from mixed module...
Compilation target object.
IRModule ScheduleToModule(te::Schedule sch, const Array< ObjectRef > &args, const std::string &name, const std::unordered_map< te::Tensor, tir::Buffer > &binds)
Create an IRModule out of a TE Schedule. It does not apply lowering passes. If you want to apply lowe...
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:290
Type-erased function used across TVM API.
runtime::Module build(const IRModule &funcs, const Target &target, const Target &target_host)
Build a device and host module for a specific target from an IRModule.
transform::Sequential HostModulePassManager(IRModule mixed_mod, Target target_host)
Configures and returns the composite Pass for the host Target after device/host from mixed module...
RAII wrapper function to enter and exit a context object similar to python&#39;s with syntax...