49 #ifndef TVM_IR_TYPE_H_
50 #define TVM_IR_TYPE_H_
227 LOG(FATAL) <<
"ValueError: Unknown TypeKind: " <<
static_cast<int>(kind);
261 v->Visit(
"kind", &
kind);
262 v->Visit(
"span", &
span);
312 v->Visit(
"kind", &
kind);
325 static constexpr
const char*
_type_key =
"GlobalTypeVar";
358 v->Visit(
"fields", &
fields);
359 v->Visit(
"span", &
span);
405 return n && n->
fields.size() == 0;
414 static constexpr
const char*
_type_key =
"TypeConstraint";
457 v->Visit(
"span", &
span);
514 v->Visit(
"kind", &
kind);
515 v->Visit(
"span", &
span);
524 static constexpr
const char*
_type_key =
"IncompleteType";
557 v->Visit(
"value", &
value);
558 v->Visit(
"span", &
span);
569 static constexpr
const char*
_type_key =
"relay.RefType";
Runtime Array container types.
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Function type.
Definition: type.h:436
bool SEqualReduce(const FuncTypeNode *other, SEqualReducer equal) const
Definition: type.h:460
static constexpr const char * _type_key
Definition: type.h:473
Type ret_type
The type of return value.
Definition: type.h:441
Array< TypeConstraint > type_constraints
potential constraint the type need to obey
Definition: type.h:450
TVM_DECLARE_FINAL_OBJECT_INFO(FuncTypeNode, TypeNode)
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:466
Array< Type > arg_types
type type of arguments
Definition: type.h:439
Array< TypeVar > type_params
The type parameters of the function.
Definition: type.h:445
void VisitAttrs(AttrVisitor *v)
Definition: type.h:452
Managed reference to FuncTypeNode.
Definition: type.h:481
FuncType(Array< Type > arg_types, Type ret_type, Array< TypeVar > type_params, Array< TypeConstraint > type_constraints, Span span=Span())
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(FuncType, Type, FuncTypeNode)
A global type variable that is used for defining new types or type aliases.
Definition: type.h:299
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:320
TypeKind kind
The kind of type parameter.
Definition: type.h:308
bool SEqualReduce(const GlobalTypeVarNode *other, SEqualReducer equal) const
Definition: type.h:315
TVM_DECLARE_FINAL_OBJECT_INFO(GlobalTypeVarNode, TypeNode)
void VisitAttrs(AttrVisitor *v)
Definition: type.h:310
static constexpr const char * _type_key
Definition: type.h:325
String name_hint
The name of the variable, this only acts as a hint to the user, and is not used for equality.
Definition: type.h:306
Managed reference to GlobalTypeVarNode.
Definition: type.h:333
TVM_DEFINE_OBJECT_REF_METHODS(GlobalTypeVar, Type, GlobalTypeVarNode)
GlobalTypeVar(String name_hint, TypeKind kind, Span span=Span())
Constructor.
Intermediate values that is used to indicate incomplete type during type inference.
Definition: type.h:508
static constexpr const char * _type_key
Definition: type.h:524
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:522
TypeKind kind
kind of the type.
Definition: type.h:511
void VisitAttrs(tvm::AttrVisitor *v)
Definition: type.h:513
bool SEqualReduce(const IncompleteTypeNode *other, SEqualReducer equal) const
Definition: type.h:518
TVM_DECLARE_FINAL_OBJECT_INFO(IncompleteTypeNode, TypeNode)
Managed reference to IncompleteTypeNode.
Definition: type.h:532
TVM_DEFINE_OBJECT_REF_METHODS(IncompleteType, Type, IncompleteTypeNode)
IncompleteType(TypeKind kind, Span span=Span())
Constructor.
Low-level raw pointer type.
Definition: type.h:151
Type element_type
The type of the element which the pointer points to.
Definition: type.h:156
TVM_DECLARE_FINAL_OBJECT_INFO(PointerTypeNode, TypeNode)
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:174
void VisitAttrs(AttrVisitor *v)
Definition: type.h:162
static constexpr const char * _type_key
Definition: type.h:180
bool SEqualReduce(const PointerTypeNode *other, SEqualReducer equal) const
Definition: type.h:167
String storage_scope
The storage scope of the pointer.
Definition: type.h:160
TVM_DEFINE_OBJECT_REF_METHODS(PointerType, Type, PointerTypeNode)
PointerType(Type element_type, String storage_scope="")
Constructor.
Primitive data types used in the low-level IR.
Definition: type.h:106
runtime::DataType dtype
The corresponding dtype field.
Definition: type.h:111
void VisitAttrs(AttrVisitor *v)
Definition: type.h:113
static constexpr const char * _type_key
Definition: type.h:121
TVM_DECLARE_FINAL_OBJECT_INFO(PrimTypeNode, TypeNode)
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:119
bool SEqualReduce(const PrimTypeNode *other, SEqualReducer equal) const
Definition: type.h:115
PrimType(runtime::DataType dtype, Span span=Span())
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(PrimType, Type, PrimTypeNode)
Reference Type High-level Relay IR.
Definition: type.h:549
RelayRefTypeNode()
Definition: type.h:554
static constexpr const char * _type_key
Definition: type.h:569
Type value
The type of value in the Reference.
Definition: type.h:552
void VisitAttrs(tvm::AttrVisitor *v)
Definition: type.h:556
bool SEqualReduce(const RelayRefTypeNode *other, SEqualReducer equal) const
Definition: type.h:561
TVM_DECLARE_FINAL_OBJECT_INFO(RelayRefTypeNode, TypeNode)
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:565
Managed reference to RelayRefTypeNode.
Definition: type.h:577
RelayRefType(Type value, Span span=Span())
TVM_DEFINE_OBJECT_REF_METHODS(RelayRefType, Type, RelayRefTypeNode)
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:137
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:121
void FreeVarHashImpl(const runtime::Object *var) const
Implementation for hash for a free var.
Definition: structural_hash.h:203
void DefHash(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:198
Definition: source_map.h:120
The type of tuple values.
Definition: type.h:350
TupleTypeNode()
Definition: type.h:355
bool SEqualReduce(const TupleTypeNode *other, SEqualReducer equal) const
Definition: type.h:362
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:366
Array< Type > fields
The type of each field in the tuple.
Definition: type.h:353
static constexpr const char * _type_key
Definition: type.h:368
TVM_DECLARE_FINAL_OBJECT_INFO(TupleTypeNode, TypeNode)
void VisitAttrs(AttrVisitor *v)
Definition: type.h:357
Managed reference to TupleTypeNode.
Definition: type.h:376
TVM_DEFINE_OBJECT_REF_METHODS(TupleType, Type, TupleTypeNode)
TupleType(Array< Type > fields, Span span=Span())
Constructor.
static TupleType Empty()
Create an empty tuple type that constains nothing.
Potential Constraints in a function.
Definition: type.h:412
TVM_DECLARE_BASE_OBJECT_INFO(TypeConstraintNode, TypeNode)
static constexpr const char * _type_key
Definition: type.h:414
static constexpr const uint32_t _type_child_slots
Definition: type.h:415
Managed reference to TypeConstraintNode.
Definition: type.h:423
TVM_DEFINE_OBJECT_REF_METHODS(TypeConstraint, Type, TypeConstraintNode)
Type is the base type of all types.
Definition: type.h:74
static constexpr const uint32_t _type_child_slots
Definition: type.h:85
static constexpr const bool _type_has_method_shash_reduce
Definition: type.h:84
Span span
Span that points to the original source code. Reserved debug information.
Definition: type.h:80
static constexpr const bool _type_has_method_sequal_reduce
Definition: type.h:83
TVM_DECLARE_BASE_OBJECT_INFO(TypeNode, Object)
static constexpr const char * _type_key
Definition: type.h:82
Type parameter in functions.
Definition: type.h:248
bool SEqualReduce(const TypeVarNode *other, SEqualReducer equal) const
Definition: type.h:265
void VisitAttrs(AttrVisitor *v)
Definition: type.h:259
void SHashReduce(SHashReducer hash_reduce) const
Definition: type.h:269
TVM_DECLARE_FINAL_OBJECT_INFO(TypeVarNode, TypeNode)
String name_hint
The name of the variable, this only acts as a hint to the user, and is not used for equality.
Definition: type.h:255
static constexpr const char * _type_key
Definition: type.h:274
TypeKind kind
The kind of type parameter.
Definition: type.h:257
Managed reference to TypeVarNode.
Definition: type.h:282
TVM_DEFINE_OBJECT_REF_METHODS(TypeVar, Type, TypeVarNode)
TypeVar(String name_hint, TypeKind kind, Span span=Span())
Constructor.
Managed reference to TypeNode.
Definition: type.h:93
TVM_DEFINE_OBJECT_REF_METHODS(Type, ObjectRef, TypeNode)
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Runtime primitive data type.
Definition: data_type.h:43
Base class of all object reference.
Definition: object.h:519
const ObjectType * as() const
Try to downcast the internal Object to a raw pointer of a corresponding type.
Definition: object.h:910
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
bool empty() const
Retun if the string is empty.
Definition: string.h:208
tvm::Span Span
Definition: base.h:65
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
bool IsVoidType(const Type &type)
Check whether the tyep represents void.
Definition: type.h:403
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Type VoidType()
Definition: type.h:397
String TypeKind2String(TypeKind kind)
Converts a TypeKind to a string.
Definition: type.h:212
TypeKind
Possible kinds of TypeVars.
Definition: type.h:201
@ kType
Definition: type.h:202
@ kBaseType
Definition: type.h:205
@ kTypeData
Definition: type.h:208
@ kConstraint
Definition: type.h:206
@ kAdtHandle
Definition: type.h:207
@ kShapeVar
Template variable in shape expression.
Definition: type.h:204
Definitions and helper macros for IR/AST nodes.
A managed object in the TVM runtime.
A map from source names to source code.