27#include <tvm/ffi/dtype.h>
174 namespace refl = tvm::ffi::reflection;
175 refl::ObjectDef<IterVarNode>()
177 .def_ro(
"var", &
IterVarNode::var, refl::AttachFieldFlag::SEqHashDefRecursive())
181 refl::AttachFieldFlag::SEqHashIgnore());
208inline IterVar::operator
PrimExpr()
const {
return (*this)->var; }
215 return "ThreadIndex";
227 return "Parallelized";
240inline constexpr bool use_default_type_traits_v<tirx::PrimVar> =
false;
243struct TypeTraits<tirx::PrimVar> :
public ObjectRefTypeTraitsBase<tirx::PrimVar> {
245 using Base::CopyFromAnyViewAfterCheck;
246 using Base::CopyToAnyView;
247 using Base::GetMismatchTypeInfo;
248 using Base::MoveFromAnyAfterCheck;
249 using Base::MoveToAny;
250 using Base::TypeSchema;
254 if (src->type_index == TypeIndex::kTVMFFINone) {
255 return tirx::PrimVar::_type_is_nullable;
257 if (src->type_index != tirx::VarNode::RuntimeTypeIndex()) {
261 details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(src->v_obj).get());
262 return details::AnyUnsafe::CheckAnyStrict<PrimType>(var->ExprNode::ty);
266 if (CheckAnyStrict(src)) {
267 if (src->type_index == TypeIndex::kTVMFFINone) {
268 return details::ObjectUnsafe::ObjectRefFromObjectPtr<tirx::PrimVar>(
nullptr);
270 return details::ObjectUnsafe::ObjectRefFromObjectPtr<tirx::PrimVar>(
271 details::ObjectUnsafe::ObjectPtrFromUnowned<tirx::VarNode>(src->v_obj));
Base class for other IR constructs that can be converted to PrimExpr. This is useful for the FFI to c...
Definition base_expr.h:438
Managed reference to PrimExprConvertibleNode.
Definition base_expr.h:449
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Definition base_expr.h:137
static PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
Range container
Definition expr.h:610
Definition source_map.h:111
Managed reference to TypeNode.
Definition base_expr.h:77
A local variable in the IR.
Definition expr.h:355
Managed reference to VarNode.
Definition expr.h:372
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
An iteration variable representing an iteration over a one dimensional interval.
Definition var.h:149
Range dom
the domain of iteration, if known, can be None For the intermediate schedule node,...
Definition var.h:155
ffi::String thread_tag
additional tag on the iteration variable, set this if this is bound already to a known thread tag.
Definition var.h:164
IterVarType iter_type
The type of the IterVar.
Definition var.h:159
static void RegisterReflection()
Definition var.h:173
PrimVar var
The looping variable.
Definition var.h:157
PrimExpr ToPrimExpr() const final
Definition var.h:171
Span span
Span that points to the original source code. Reserved debug information.
Definition var.h:169
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition var.h:184
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.IterVar", IterVarNode, PrimExprConvertibleNode)
Iteration Variable, represents an iteration over an integer interval.
Definition var.h:194
IterVar(Range dom, PrimVar var, IterVarType iter_type, ffi::String thread_tag="", Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IterVar, PrimExprConvertible, IterVarNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(IterVarNode)
Checked scalar view over a VarNode.
Definition var.h:46
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(PrimVar, PrimExpr, VarNode)
PrimVar(ffi::String name, Type type_annotation, Span span=Span())
Construct a scalar variable directly from a checked type annotation.
Definition var.h:53
static constexpr bool _type_container_is_exact
Definition var.h:68
PrimVar CopyWithSuffix(const ffi::String &suffix) const
Definition var.h:60
PrimVar(ffi::String name, PrimType dtype=PrimType::Int(32), Span span=Span())
Construct a scalar variable directly from a primitive type.
Definition var.h:49
PrimVar CopyWithDType(PrimType dtype) const
Definition var.h:63
Copy-on-write helper macro for IR ffi::ObjectRef types.
IR/AST nodes for TVM types shared across IR variants.
Definition iter_affine_map.h:231
const char * IterVarType2String(IterVarType t)
Definition var.h:210
IterVarType
Type of iteration variable. Each IterVar have a specific type.
Definition var.h:80
@ kThreadIndex
The IterVar itself is a thread-index of a fixed thread launching group. Note that this is already ass...
Definition var.h:97
@ kUnrolled
The execution is unrolled.
Definition var.h:128
@ kCommReduce
Communicative reduction. Cannot be directly parallelized.
Definition var.h:104
@ kTensorized
Marks boundary of tensorization intrinsic.
Definition var.h:140
@ kVectorized
The loop is vectorized.
Definition var.h:132
@ kDataPar
Data parallel iteration. This normally corresponds to axis of Tensor. Allow all IterVar manipulations...
Definition var.h:89
@ kParallelized
The loop is parallelized.
Definition var.h:136
@ kOpaque
IterVar is opaque,.
Definition var.h:122
@ kOrdered
Serial loops with loop carry dependency, the iteration must execute in order. Cannot be re-ordered.
Definition var.h:112
tvm::Var Var
Definition var.h:38
ffi::Array< Range > Region
Definition var.h:71
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
ObjectRefTypeTraitsBase< tirx::PrimVar > Base
Definition var.h:244
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition var.h:253
static TVM_FFI_INLINE std::optional< tirx::PrimVar > TryCastFromAnyView(const TVMFFIAny *src)
Definition var.h:265