23#ifndef TVM_S_TIR_SCHEDULE_STATE_H_
24#define TVM_S_TIR_SCHEDULE_STATE_H_
26#include <tvm/ffi/reflection/registry.h>
32#include <unordered_map>
111 std::unordered_map<StmtSRef, SBlockInfo, ffi::ObjectPtrHash, ffi::ObjectPtrEqual>
block_info;
113 std::unordered_map<const StmtNode*, StmtSRef>
stmt2ref;
126 namespace refl = tvm::ffi::reflection;
127 refl::ObjectDef<ScheduleStateNode>()
Managed reference class to IRModuleNode.
Definition module.h:255
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
The state of scheduling, which exposes a Replace method as the primary interface for all the scheduli...
Definition state.h:102
static void RegisterReflection()
Definition state.h:125
IRModule mod
The AST of the module being scheduled.
Definition state.h:105
bool IsAffineBlockBinding(const StmtSRef &block_sref) const
Check a cached flag indicating if the specific block has quasi-affine bindings.
Definition state.h:187
SBlockScope GetSBlockScope(const StmtSRef &scope_root) const
Get the SBlockScope correpsonding to the sref of scope root block.
Definition state.h:179
SBlockInfo GetSBlockInfo(const StmtSRef &block_sref) const
Returns the SBlockInfo correpsonding to the block sref.
void DebugVerify() const
Trigger the verification according to the debug_mask bitmask. 1) If the bitmask kVerifySRefTree is on...
static constexpr const bool _type_mutable
Definition state.h:162
bool IsStagePipeline(const StmtSRef &scope_root) const
Check a cached flag indicating if a block scope is an equivalence of a stage pipeline.
Definition state.h:204
int debug_mask
Do extra correctness checking after the class creation and each time after calling the Replace method...
Definition state.h:119
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.ScheduleState", ScheduleStateNode, ffi::Object)
void Replace(const tirx::StmtSRef &src_sref, const Stmt &tgt_stmt, const ffi::Map< SBlock, SBlock > &block_sref_reuse)
Replace the part of the AST, as being pointed to by src_sref, with a specific statement tgt_stmt,...
bool enable_check
Whether to enable prequisite checks for schedule primitives.
Definition state.h:123
std::unordered_map< StmtSRef, SBlockInfo, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > block_info
Mapping from a block sref to its correpsonding SBlockInfo, tracking the dependency inside the block s...
Definition state.h:111
void UpdateScopeSBlockInfo(const Stmt &stmt)
Recalculate the SBlockInfo recursively under stmt. If stmt is a SBlock itself, we will not reset its ...
std::unordered_map< const StmtNode *, StmtSRef > stmt2ref
The reverse mapping from block/for-loop to their corresponding srefs.
Definition state.h:113
bool IsRegionCoveredConsumer(const StmtSRef &consumer_block_sref) const
Check a cached flag indicating if each of the specific consumer block's read region is fully produced...
Definition state.h:196
Managed reference to ScheduleStateNode.
Definition state.h:213
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(ScheduleState, ffi::ObjectRef, ScheduleStateNode)
ScheduleState(IRModule mod, int debug_mask=0, bool enable_check=true)
Construct a schedule state from an IRModule.
Managed reference to SBlockScopeNode.
Definition sblock_scope.h:296
Managed reference to StmtSRefNode.
Definition sblock_scope.h:107
Container of all statements.
Definition stmt.h:67
IRModule that holds the functions and type definitions.
ScheduleDebugMask
The bitmask of the debug flag in the ScheduleStateNode.
Definition state.h:83
@ kVerifySRefTree
Verify the correctness of the sref tree.
Definition state.h:85
@ kVerifyCachedFlags
Verify the correctness of affine_binding, region_cover and stage_pipeline.
Definition state.h:87
Definition axis_group_graph.h:39
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
Definition of two pillar data structure for TensorIR scheduling: StmtSRef, SBlockScope.
The information about a TensorIR block, it contains two categories of information 1) Info on the bloc...
Definition state.h:47
bool region_cover
Property of a block, indicating each of the block's read regions is fully produced by its producers.
Definition state.h:57
SBlockInfo(SBlockScope scope, bool affine_binding=false, bool region_cover=false, bool stage_pipeline=false)
Definition state.h:71
SBlockScope scope
Property of a block scope rooted at the block, storing dependencies in the scope.
Definition state.h:49
bool affine_binding
Property of a block, indicating the block realization binding is quasi-affine.
Definition state.h:52
bool stage_pipeline
This property indicates that the block scope (rooted at its corresponding block) is equivalent to of ...
Definition state.h:67