48 #ifndef TVM_ARITH_ITER_AFFINE_MAP_H_
49 #define TVM_ARITH_ITER_AFFINE_MAP_H_
71 static constexpr
const char*
_type_key =
"arith.IterMapExpr";
105 v->Visit(
"source", &
source);
106 v->Visit(
"extent", &
extent);
110 equal->MarkGraphNode();
122 static constexpr
const char*
_type_key =
"arith.IterMark";
161 v->Visit(
"source", &
source);
163 v->Visit(
"extent", &
extent);
164 v->Visit(
"scale", &
scale);
179 static constexpr
const char*
_type_key =
"arith.IterSplitExpr";
228 v->Visit(
"args", &
args);
229 v->Visit(
"base", &
base);
241 static constexpr
const char*
_type_key =
"arith.IterSumExpr";
296 v->Visit(
"errors", &
errors);
301 static constexpr
const char*
_type_key =
"arith.IterMapResult";
414 bool simplify_trivial_iterators =
true);
Algebra expression simplifications.
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
Base node of all primitive expressions.
Definition: expr.h:86
Reference to PrimExprNode.
Definition: expr.h:115
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:137
virtual void MarkGraphNode()=0
Mark current comparison as graph node in hashing. Graph node hash will depends on the graph structure...
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:121
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:629
Base class of all iter map expressions.
Definition: iter_affine_map.h:66
TVM_DECLARE_BASE_OBJECT_INFO(IterMapExprNode, PrimExprNode)
static constexpr const char * _type_key
Definition: iter_affine_map.h:71
static constexpr const uint32_t _type_child_slots
Definition: iter_affine_map.h:72
void VisitAttrs(tvm::AttrVisitor *v)
Definition: iter_affine_map.h:69
Managed reference to IterMapExprNode.
Definition: iter_affine_map.h:80
TVM_DEFINE_OBJECT_REF_METHODS(IterMapExpr, PrimExpr, IterMapExprNode)
Result of DetectIterMap.
Definition: iter_affine_map.h:275
Array< IterSumExpr > indices
Definition: iter_affine_map.h:278
void VisitAttrs(tvm::AttrVisitor *v)
Definition: iter_affine_map.h:295
static constexpr const char * _type_key
Definition: iter_affine_map.h:301
TVM_DECLARE_FINAL_OBJECT_INFO(IterMapResultNode, Object)
Array< String > errors
Definition: iter_affine_map.h:282
PrimExpr padding_predicate
Boolean expression indicating if a specific value w.
Definition: iter_affine_map.h:292
Managed reference to IterMapResultNode.
Definition: iter_affine_map.h:309
IterMapResult()
Definition: iter_affine_map.h:312
IterMapResultNode * operator->() const
Definition: iter_affine_map.h:315
Mark the source as an iterator in [0, extent).
Definition: iter_affine_map.h:91
static constexpr const bool _type_has_method_shash_reduce
Definition: iter_affine_map.h:121
void VisitAttrs(tvm::AttrVisitor *v)
Definition: iter_affine_map.h:104
static constexpr const bool _type_has_method_sequal_reduce
Definition: iter_affine_map.h:120
bool SEqualReduce(const IterMarkNode *other, SEqualReducer equal) const
Definition: iter_affine_map.h:109
TVM_DECLARE_FINAL_OBJECT_INFO(IterMarkNode, Object)
PrimExpr extent
The extent of the iteration.
Definition: iter_affine_map.h:101
PrimExpr source
The source expression, can either be a IterSumExpr or a Var.
Definition: iter_affine_map.h:97
void SHashReduce(SHashReducer hash_reduce) const
Definition: iter_affine_map.h:114
static constexpr const char * _type_key
Definition: iter_affine_map.h:122
Managed reference to IterMarkExprNode.
Definition: iter_affine_map.h:130
TVM_DEFINE_OBJECT_REF_COW_METHOD(IterMarkNode)
IterMark(PrimExpr source, PrimExpr extent)
constructor.
TVM_DEFINE_OBJECT_REF_METHODS(IterMark, ObjectRef, IterMarkNode)
Split of an iterator.
Definition: iter_affine_map.h:148
static constexpr const char * _type_key
Definition: iter_affine_map.h:179
PrimExpr lower_factor
The lower factor to split the source.
Definition: iter_affine_map.h:153
void VisitAttrs(tvm::AttrVisitor *v)
Definition: iter_affine_map.h:160
TVM_DECLARE_FINAL_OBJECT_INFO(IterSplitExprNode, IterMapExprNode)
IterMark source
The source marked iterator.
Definition: iter_affine_map.h:151
PrimExpr scale
Additional scale.
Definition: iter_affine_map.h:157
void SHashReduce(SHashReducer hash_reduce) const
Definition: iter_affine_map.h:172
bool SEqualReduce(const IterSplitExprNode *other, SEqualReducer equal) const
Definition: iter_affine_map.h:167
PrimExpr extent
The extent of the split.
Definition: iter_affine_map.h:155
Managed reference to IterSplitExprNode.
Definition: iter_affine_map.h:187
TVM_DEFINE_OBJECT_REF_COW_METHOD(IterSplitExprNode)
TVM_DEFINE_OBJECT_REF_METHODS(IterSplitExpr, IterMapExpr, IterSplitExprNode)
IterSplitExpr(IterMark source, PrimExpr lower_factor, PrimExpr extent, PrimExpr scale)
constructor
IterSplitExpr(IterMark source)
constructor from just source.
IterSplitExpr(IterMark source, PrimExpr scale)
constructor from just source.
Fuse multiple iterators by summing them with scaling.
Definition: iter_affine_map.h:219
void SHashReduce(SHashReducer hash_reduce) const
Definition: iter_affine_map.h:236
bool SEqualReduce(const IterSumExprNode *other, SEqualReducer equal) const
Definition: iter_affine_map.h:232
static constexpr const char * _type_key
Definition: iter_affine_map.h:241
Array< IterSplitExpr > args
The args to the sum.
Definition: iter_affine_map.h:222
TVM_DECLARE_FINAL_OBJECT_INFO(IterSumExprNode, IterMapExprNode)
PrimExpr base
The base offset.
Definition: iter_affine_map.h:224
void VisitAttrs(tvm::AttrVisitor *v)
Definition: iter_affine_map.h:227
Managed reference to IterSumExprNode.
Definition: iter_affine_map.h:249
IterSumExpr(Array< IterSplitExpr > args, PrimExpr base)
constructor.
TVM_DEFINE_OBJECT_REF_COW_METHOD(IterSumExprNode)
TVM_DEFINE_OBJECT_REF_METHODS(IterSumExpr, IterMapExpr, IterSumExprNode)
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
Base class of all object reference.
Definition: object.h:519
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:605
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
A new diagnostic interface for TVM error reporting.
Array< Array< IterMark > > SubspaceDivide(const Array< PrimExpr > &bindings, const Map< Var, Range > &input_iters, const Array< Var > &sub_iters, const PrimExpr &predicate, IterMapLevel check_level, arith::Analyzer *analyzer, bool simplify_trivial_iterators=true)
Detect if bindings can be written as [a_0*e_0 + b_0 + c_0, a_1*e_1 + b_1, ..., a_n*e_n + b_n].
IterMapLevel
Mapping level for iterators.
Definition: iter_affine_map.h:263
@ NoCheck
Definition: iter_affine_map.h:269
@ Bijective
Definition: iter_affine_map.h:265
@ Surjective
Definition: iter_affine_map.h:267
PrimExpr NormalizeIterMapToExpr(const PrimExpr &expr)
Given an expression that may contain IterMapExpr, transform it to normal PrimExpr.
Array< PrimExpr > IterMapSimplify(const Array< PrimExpr > &indices, const Map< Var, Range > &input_iters, const PrimExpr &input_pred, IterMapLevel check_level, arith::Analyzer *analyzer, bool simplify_trivial_iterators=true)
Use IterVarMap detector to rewrite and simplify the indices.
IterMapResult DetectIterMap(const Array< PrimExpr > &indices, const Map< Var, Range > &input_iters, const PrimExpr &predicate, IterMapLevel check_level, arith::Analyzer *analyzer, bool simplify_trivial_iterators=true)
Detect if indices can be written as [y_0 + c_0, y_1 + c_1, ..., y_n + c_n].
IterSumExpr NormalizeToIterSum(PrimExpr index, const Map< Var, Range > &input_iters, arith::Analyzer *analyzer)
Rewrite index as IterSumExpr.
Map< Var, PrimExpr > InverseAffineIterMap(const Array< IterSumExpr > &iter_map, const Array< PrimExpr > outputs)
Apply the inverse of the affine transformation to the outputs.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal