tvm
Classes | Namespaces | Macros | Functions
transform.h File Reference
#include <tvm/ir/diagnostic.h>
#include <tvm/ir/instrument.h>
#include <tvm/ir/module.h>
#include <tvm/runtime/container/array.h>
#include <tvm/runtime/container/string.h>
#include <tvm/support/with.h>
#include <string>
#include <utility>
Include dependency graph for transform.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tvm::transform::PassContextNode
 PassContextNode contains the information that a pass can rely on, such as analysis results. More...
 
class  tvm::transform::PassContext
 PassContext that is used to configure the pass behavior. More...
 
class  tvm::transform::PassInfoNode
 Meta data that will be used to help optimization and analysis. More...
 
class  tvm::transform::PassInfo
 Managed reference class for PassInfoNode. More...
 
class  tvm::transform::PassNode
 PassNode is the base type of differnt types of optimization passes. It is designed as a pure class and implemented by different pass subclasses at different granularity of Relay/Relax nodes. More...
 
class  tvm::transform::Pass
 
class  tvm::transform::SequentialNode
 The SequentialNode contains a set of passes that transform Relay/Relax programs from one AST to another semantically equivalent one. More...
 
class  tvm::transform::Sequential
 

Namespaces

 tvm
 runtime implementation for LibTorch/TorchScript.
 
 tvm::transform
 

Macros

#define TVM_PASS_CTX_CONFIG_VAR_DEF   static TVM_ATTRIBUTE_UNUSED uint32_t __make_PassContext_tid
 
#define TVM_REGISTER_PASS_CONFIG_OPTION(Key, ValueType)
 Helper macro to register the object type to runtime. Makes sure that the runtime type table is correctly populated. More...
 

Functions

Pass tvm::transform::CreateModulePass (const runtime::TypedPackedFunc< IRModule(IRModule, PassContext)> &pass_func, int opt_level, String name, Array< runtime::String > required, bool traceable=false)
 
Pass tvm::transform::ApplyPassToFunction (Pass pass, String func_name_regex, bool error_if_no_function_matches_regex=false)
 
Pass tvm::transform::PrintIR (String header="", bool show_meta_data=false)
 A special trace pass that prints the header and IR to LOG(INFO). More...
 

Detailed Description

This file implements a pass manager. The pass manager manages a sequence of IRModule -> IRModule transformation passes over a particlar unit of AST. The design is largely inspired from LLVM's pass manager and modern deep learning frameworks that perform tensor->tensor transformations.

The responsibilities of a traditional compiler pass manager usually involves:

Similar to LLVM's pass manager, we designed the Relay/Relax pass manager to work different granularity, i.e. module level, function level, and even sequential passe that contains a host of passes.

However, we also extend the functionality of the traditional pass manager with the consideration of requirements/convention from deep learning frameworks, such as Pytorch and Gluon, etc. Each pass in the Relay/Relax pass manager performs the IRModule -> IRModule transformation. All different types of passes, including the sequential-level pass object, are essentially pass objects. This design, therefore, effectively provides users a consistent and convenient interface, i.e. Pass, to play with. It offers a means to ease the development and testing of Relay/Relax passes. For example, with the pass manager, external users will be able to have custom passes correctly scheduled without having to modify a single handcrafted pass order.

In the future we need to describe constraints between passes. For example, we may want to preserve dependencies between different passes and validate them on the completion of a certain pass.

We also need to store side information and import the error reporting system.

Macro Definition Documentation

◆ TVM_PASS_CTX_CONFIG_VAR_DEF

#define TVM_PASS_CTX_CONFIG_VAR_DEF   static TVM_ATTRIBUTE_UNUSED uint32_t __make_PassContext_tid

◆ TVM_REGISTER_PASS_CONFIG_OPTION

#define TVM_REGISTER_PASS_CONFIG_OPTION (   Key,
  ValueType 
)
Value:
::tvm::transform::PassContext::RegisterConfigOption<ValueType>(Key)
#define TVM_PASS_CTX_CONFIG_VAR_DEF
Definition: transform.h:325
#define TVM_STR_CONCAT(__x, __y)
Definition: object.h:715

Helper macro to register the object type to runtime. Makes sure that the runtime type table is correctly populated.

Use this macro in the cc file for each terminal class.