tvm
Classes | Namespaces | Enumerations | Functions
type.h File Reference

IR/AST nodes for the unified type system in TVM. More...

#include <tvm/ir/source_map.h>
#include <tvm/node/node.h>
#include <tvm/runtime/container/array.h>
#include <tvm/runtime/data_type.h>
#include <tvm/runtime/object.h>
#include <string>
Include dependency graph for type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tvm::TypeNode
 Type is the base type of all types. More...
 
class  tvm::Type
 Managed reference to TypeNode. More...
 
class  tvm::PrimTypeNode
 Primitive data types used in the low-level IR. More...
 
class  tvm::PrimType
 
class  tvm::PointerTypeNode
 Low-level raw pointer type. More...
 
class  tvm::PointerType
 
class  tvm::TypeVarNode
 Type parameter in functions. More...
 
class  tvm::TypeVar
 Managed reference to TypeVarNode. More...
 
class  tvm::GlobalTypeVarNode
 A global type variable that is used for defining new types or type aliases. More...
 
class  tvm::GlobalTypeVar
 Managed reference to GlobalTypeVarNode. More...
 
class  tvm::TupleTypeNode
 The type of tuple values. More...
 
class  tvm::TupleType
 Managed reference to TupleTypeNode. More...
 
class  tvm::TypeConstraintNode
 Potential Constraints in a function. More...
 
class  tvm::TypeConstraint
 Managed reference to TypeConstraintNode. More...
 
class  tvm::FuncTypeNode
 Function type. More...
 
class  tvm::FuncType
 Managed reference to FuncTypeNode. More...
 
class  tvm::IncompleteTypeNode
 Intermediate values that is used to indicate incomplete type during type inference. More...
 
class  tvm::IncompleteType
 Managed reference to IncompleteTypeNode. More...
 
class  tvm::RelayRefTypeNode
 Reference Type High-level Relay IR. More...
 
class  tvm::RelayRefType
 Managed reference to RelayRefTypeNode. More...
 

Namespaces

 tvm
 runtime implementation for LibTorch/TorchScript.
 

Enumerations

enum  tvm::TypeKind : int {
  tvm::kType = 0 , tvm::kShapeVar = 1 , tvm::kBaseType = 2 , tvm::kConstraint = 4 ,
  tvm::kAdtHandle = 5 , tvm::kTypeData = 6
}
 Possible kinds of TypeVars. More...
 

Functions

String tvm::TypeKind2String (TypeKind kind)
 Converts a TypeKind to a string. More...
 
Type tvm::VoidType ()
 
bool tvm::IsVoidType (const Type &type)
 Check whether the tyep represents void. More...
 

Detailed Description

IR/AST nodes for the unified type system in TVM.

We use Relay's type system as the unified type system throughout the stack.

This file contains types that are common across IR variants.

Relation between Type and runtime::DataType

Besides Type, we also store a dtype field in the low-level PrimExpr. runtime::DataType(dtype) provides coarse grained type information during compile time and runtime. It is eagerly built in low-level expression construction and can be used for quick type checking in the low-level IR. For example, when an Expr's dtype is int32, we know for sure that its type is also int32.

On the other hand, Type provides more fine grained information. For example, a low level expression can have DataType::Handle() as its dtype and MemRef[float32] as its type. Types are usually lazily constructed via type checking, so they may not readily be available during IR construction.

The unified Type serves as a common bridge across IR dialects. For example, we require all the functions to have a type signature, which allow us to build cross dialect function calls.