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 
33 #include <tvm/ir/module.h>
34 #include <tvm/ir/transform.h>
36 #include <tvm/support/with.h>
37 #include <tvm/target/target.h>
38 #include <tvm/te/schedule_pass.h>
39 #include <tvm/tir/function.h>
40 
41 #include <string>
42 #include <unordered_map>
43 #include <unordered_set>
44 #include <utility>
45 #include <vector>
46 
47 namespace tvm {
49 
58 
67 
76 
83 TVM_DLL IRModule LowerModule(IRModule mod, bool simple_mode = false);
84 
93 TVM_DLL IRModule LowerPrimFunc(tvm::tir::PrimFunc func, const std::string& name,
94  bool simple_mode = false);
95 
109  const std::string& name,
110  const std::unordered_map<te::Tensor, tir::Buffer>& binds,
111  GlobalVarSupply global_var_supply, bool simple_mode = false);
112 
125  const std::string& name,
126  const std::unordered_map<te::Tensor, tir::Buffer>& binds,
127  GlobalVarSupply global_var_supply, bool simple_mode = false);
128 
140 IRModule ScheduleToModule(te::Schedule sch, const Array<ObjectRef>& args, const std::string& name,
141  const std::unordered_map<te::Tensor, tir::Buffer>& binds,
142  GlobalVarSupply global_var_supply);
150 TVM_DLL runtime::Module build(const IRModule& funcs, const Target& target,
151  const Target& target_host);
152 
162 TVM_DLL runtime::Module build(const Map<Target, IRModule>& input, const Target& target_host);
163 
173 TVM_DLL runtime::Module build(const Map<String, IRModule>& input, const Target& target_host);
174 } // namespace tvm
175 
176 #endif // TVM_DRIVER_DRIVER_API_H_
Managed reference class to GlobalVarSupplyNode.
Definition: global_var_supply.h:96
Managed reference class to IRModuleNode.
Definition: module.h:366
Managed reference class to TargetNode.
Definition: target.h:200
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Module container of TVM.
Definition: module.h:79
Global schedule container For operations and all the operations they depend on. The schedule per Oper...
Definition: schedule.h:326
Managed reference to PrimFuncNode.
Definition: function.h:145
Definition: transform.h:517
GlobalVarSupply that can be used to generate unique.
IRModule that holds the functions and type definitions.
tvm::transform::Pass Pass
Definition: transform.h:39
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:290
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
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.
transform::Sequential DeviceModulePassManager(IRModule mixed_mod, Target target)
Configures and returns the composite Pass for the device Target after device/host from mixed module.
IRModule ScheduleToModule(te::Schedule sch, const Array< ObjectRef > &args, const std::string &name, const std::unordered_map< te::Tensor, tir::Buffer > &binds, GlobalVarSupply global_var_supply)
Create an IRModule out of a TE Schedule. It does not apply lowering passes. If you want to apply lowe...
IRModule LowerSchedule(te::Schedule sch, const Array< te::Tensor > &args, const std::string &name, const std::unordered_map< te::Tensor, tir::Buffer > &binds, GlobalVarSupply global_var_supply, bool simple_mode=false)
Build an IRModule given a TE schedule, args and binds. This function also applies the lowering passes...
IRModule LowerModule(IRModule mod, bool simple_mode=false)
Lower an IRModule (optimize with it with the pass list defined in CreatePassList)
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 MixedModulePassManager(IRModule mixed_mod, Target target)
Configures and returns the composite Pass for the fused module (pre split) that contains device and h...
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...
Type-erased function used across TVM API.
Collection of Schedule pass functions.
Compilation target object.
TIR Function.
RAII wrapper function to enter and exit a context object similar to python's with syntax.