48 #ifndef TVM_AUTO_SCHEDULER_LOOP_STATE_H_
49 #define TVM_AUTO_SCHEDULER_LOOP_STATE_H_
51 #include <dmlc/common.h>
55 #include <unordered_map>
60 namespace auto_scheduler {
111 v->Visit(
"iters", &iters);
112 v->Visit(
"op_type", &op_type);
113 v->Visit(
"compute_at", &compute_at);
116 static constexpr
const char* _type_key =
"auto_scheduler.Stage";
163 return ::dmlc::HashCombine(std::hash<int>()(k.first), std::hash<int>()(k.second));
172 static constexpr
const char* _type_key =
"auto_scheduler.AttachMap";
203 const std::vector<IterKey>& new_iters);
226 static void DeleteStageEntry(
AttachMapNode* pnode,
int stage_id);
259 v->Visit(
"stages", &stages);
260 v->Visit(
"transform_steps", &transform_steps);
261 v->Visit(
"concrete", &concrete);
264 static constexpr
const char* _type_key =
"auto_scheduler.State";
354 bool inner_to_outer =
true);
378 bool factor_or_nparts);
466 bool operator()(const ::tvm::auto_scheduler::State& lhs,
467 const ::tvm::auto_scheduler::State& rhs)
const {
468 return lhs.
ToStr() == rhs.ToStr();
475 std::size_t operator()(const ::tvm::auto_scheduler::State& state)
const {
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
stores the compute_at relation between stages This stores a bi-directional mapping from stages and it...
Definition: loop_state.h:159
std::unordered_map< IterKey, std::vector< StageKey >, IterKeyHash > iter_to_attached_stages
A Map to store the mapping of iterator to the stages attached to it.
Definition: loop_state.h:170
std::unordered_map< StageKey, IterKey > stage_to_attach_iter
A Map to store the mapping of stage to its attached iterator.
Definition: loop_state.h:168
TVM_DECLARE_FINAL_OBJECT_INFO(AttachMapNode, Object)
Managed reference to AttachMapNode.
Definition: loop_state.h:180
TVM_DEFINE_OBJECT_REF_COW_METHOD(AttachMapNode)
void DeleteStage(int stage_id)
Delete the entry of a specific stage. This is a public wrapper of DeleteStageEntry.
TVM_DEFINE_OBJECT_REF_METHODS(AttachMap, ObjectRef, AttachMapNode)
AttachMap ApplyStageIdOffset(int start_id, int offset=1) const
Traverse through stage_to_attach_iter and iter_to_attached_stages map, add offset to stage indexes th...
void UpdateIters(const std::vector< IterKey > &original_iters, const std::vector< IterKey > &new_iters)
Find the relations of original iterators in AttachMap, and update them with the new iterators....
void SetComputeAtIter(int stage_id, int target_stage_id, int target_iter_id)
Process the stage/iterator mapping after compute at.
Managed reference to ComputeDAGNode.
Definition: compute_dag.h:219
Managed reference to IteratorNode.
Definition: transform_step.h:144
A op stage in the compute declaration. Similar to te::Stage in include/tvm/te/schedule....
Definition: loop_state.h:96
TVM_DECLARE_FINAL_OBJECT_INFO(StageNode, Object)
ComputeAtKind compute_at
The compute location of this stage.
Definition: loop_state.h:105
Array< Iterator > iters
The iterators in this stage.
Definition: loop_state.h:101
StageAttributes attrs
Other stage-level attributes.
Definition: loop_state.h:107
te::Operation op
The operator of this stage.
Definition: loop_state.h:99
StageKind op_type
The type of this stage.
Definition: loop_state.h:103
void VisitAttrs(tvm::AttrVisitor *v)
Definition: loop_state.h:109
Managed reference to StageNode.
Definition: loop_state.h:124
Stage(te::Operation op)
The constructor.
TVM_DEFINE_OBJECT_REF_METHODS(Stage, ObjectRef, StageNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(StageNode)
Stage(te::Operation op, StageKind op_type, const Array< Iterator > &iters, ComputeAtKind compute_at, StageAttributes attrs)
The constructor.
A state in the search process. It consists of the current loop structure and a list of transformation...
Definition: loop_state.h:235
void VisitAttrs(tvm::AttrVisitor *v)
Definition: loop_state.h:258
Optional< ObjectRef > current_compute_dag
The up-to-date ComputeDAG of this state. The default value is an empty NullOpt, meaning the dag of th...
Definition: loop_state.h:251
Array< Stage > stages
Current stages and loop structures.
Definition: loop_state.h:238
Array< Step > transform_steps
History transformation steps.
Definition: loop_state.h:240
TVM_DECLARE_FINAL_OBJECT_INFO(StateNode, Object)
bool concrete
Indicate whether this state has unfilled tile sizes. A concrete state means that all tile sizes of th...
Definition: loop_state.h:256
AttachMap attach_map
The attach relations of stages and iterators. This is used to track the compute at operation.
Definition: loop_state.h:245
Managed reference to StateNode.
Definition: loop_state.h:272
void compute_at(int stage_id, int target_stage_id, const Iterator &target_iter)
The schedule primitive corresponding to te::Stage::compute_at.
void reorder(int stage_id, const Array< Iterator > &order)
The schedule primitive corresponding to te::Stage::reorder.
int rfactor(int stage_id, const Iterator &it, int factor_iter_id, const ComputeDAG &dag)
The schedule primitive corresponding to te::Schedule::rfactor.
Iterator parallel(int stage_id, const Iterator &it)
The schedule primitive corresponding to te::Stage::parallel.
Array< Iterator > follow_fused_split(int stage_id, const Iterator &it, const Array< Integer > &src_step_ids, int level, bool factor_or_nparts)
The schedule primitive similar to split, but uses split factors from fused previous steps.
int cache_write(int stage_id, const String &scope_name, const ComputeDAG &dag)
The schedule primitive corresponding to te::Schedule::cache_write.
Array< Iterator > follow_split(int stage_id, const Iterator &it, int src_step_id, int n_split)
The schedule primitive similar to split, but uses split factors from previous steps.
int cache_read(int stage_id, const String &scope_name, const Array< Integer > &reader_stage_ids, const ComputeDAG &dag)
The schedule primitive corresponding to te::Schedule::cache_read.
Array< Iterator > split(int stage_id, const Iterator &it, const Array< Optional< Integer >> &lengths, bool inner_to_outer=true)
The schedule primitive corresponding to te::Stage::split.
void compute_root(int stage_id)
The schedule primitive corresponding to te::Stage::compute_root.
Iterator fuse(int stage_id, const Array< Iterator > &iters)
The schedule primitive corresponding to te::Stage::fuse.
Iterator vectorize(int stage_id, const Iterator &it)
The schedule primitive corresponding to te::Stage::vectorize.
State(const Array< te::Operation > &ops)
The constructor.
void compute_inline(int stage_id)
The schedule primitive corresponding to te::Stage::compute_inline.
Iterator unroll(int stage_id, const Iterator &it, int max_unroll=-1)
The schedule primitive corresponding to te::Stage::unroll.
void storage_align(int stage_id, const Iterator &it, int factor, int offset)
The schedule primitive corresponding to te.Stage.storage_align.
String ToStr(bool delete_trivial_loop=true) const
Pretty-print the state to a human readable string.
void pragma(int stage_id, const Iterator &it, const String &pragma_type)
The schedule primitive corresponding to te.Stage.pragma.
TVM_DEFINE_OBJECT_REF_COW_METHOD(StateNode)
TVM_DEFINE_OBJECT_REF_METHODS(State, ObjectRef, StateNode)
Iterator bind(int stage_id, const Iterator &it, IteratorAnnotation thread_type)
The schedule primitive corresponding to te::Stage::bind.
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:98
Operation that produces tensors.
Definition: tensor.h:47
std::pair< int, int > IterKey
Use stage_id and iter_id to represent a iterator.
Definition: loop_state.h:149
ComputeAtKind
The type of compute location.
Definition: loop_state.h:75
@ kInlined
Compute inlined.
@ kIter
Compute at some iterator.
IteratorAnnotation
The type of an iterator's annotation.
Definition: transform_step.h:80
StageKind
The type of a stage.
Definition: loop_state.h:67
@ kCompute
A compute stage.
@ kPlaceholder
A placeholder stage.
int StageKey
Use stage_id to represent a stage.
Definition: loop_state.h:147
Definition: extracted_task.h:30
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Definition: loop_state.h:161
std::size_t operator()(const IterKey &k) const
Definition: loop_state.h:162
Stage-level attributes.
Definition: loop_state.h:85
int auto_unroll_max_step
The maximum steps for the pragma auto_unroll_max_step.
Definition: loop_state.h:87
int storage_offset
The storage offset for the schedule primitive storage_align.
Definition: loop_state.h:89
String-aware ObjectRef equal functor.
Definition: base.h:40