tvm
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
tvm::s_tir Namespace Reference

Namespaces

namespace  attr
 
namespace  backend
 
namespace  meta_schedule
 
namespace  transform
 

Classes

class  Instruction
 Managed reference to InstructionNode. More...
 
class  InstructionKind
 Managed reference to InstructionKindObj. More...
 
class  InstructionKindDef
 Temporary builder for a canonical named instruction kind. More...
 
class  InstructionKindObj
 Kind of an instruction, e.g. Split, Reorder, etc. Besides the name, every kind of instruction has its own properties, including: 1) A boolean indicating if the instruction is pure, i.e. change nothing in the schedule state 2) A functor that applies the instruction to a TensorIR schedule 3) A functor that converts the instruction to a statement in python syntax 4) A functor that serialize its attributes to JSON 5) A functor that deserialize its attributes from JSON. More...
 
class  InstructionNode
 Schedule instructions each corresponds to a schedule primitive. More...
 
class  IterVar
 Iteration Variable, represents an iteration over an integer interval. More...
 
class  IterVarNode
 An iteration variable representing an iteration over a one dimensional interval. More...
 
class  LinearCongruentialEngine
 This linear congruential engine is a drop-in replacement for std::minstd_rand. It strictly corresponds to std::minstd_rand and is designed to be platform-independent. More...
 
class  LoopRV
 Managed reference to LoopRVNode. More...
 
class  LoopRVNode
 A random variable that evaluates to a TensorIR for loop. More...
 
class  MatchTensorRegion
 Managed reference to MatchTensorRegionNode. More...
 
class  MatchTensorRegionNode
 Match introduces a constraint that the source tensor region can be remapped to the data layout specified by the tensor field. The constraint can be checked in later part of lowering (or optionally during runtime). More...
 
struct  MemCpyDetails
 Helper struct for return value of IdentifyMemCpy. More...
 
class  SBlock
 Managed reference to SBlockNode. More...
 
struct  SBlockInfo
 The information about a TensorIR block, it contains two categories of information 1) Info on the block scope rooted at a specific block, including dependency tracking, flags indicating if the scope is a stage pipeline, etc. 2) Info on the block itself, including if the block has a quasi-affine binding, if the regions it reads are completely covered by their producers, etc. More...
 
class  SBlockNode
 A block is a basic schedule unit in TIR. More...
 
class  SBlockRealize
 Managed reference to BlockRealizeNode. More...
 
class  SBlockRealizeNode
 A block realization node represents execution of the block at the binding values. More...
 
class  SBlockRV
 Managed reference to SBlockRVNode. More...
 
class  SBlockRVNode
 A random variable that evaluates to a TensorIR block. More...
 
class  Schedule
 Managed reference to ScheduleObj. More...
 
class  ScheduleObj
 The user-facing schedule class. More...
 
class  ScheduleState
 Managed reference to ScheduleStateObj. More...
 
class  ScheduleStateObj
 The state of scheduling, which exposes a Replace method as the primary interface for all the scheduling primitives to manipulate the TensorIR. More...
 
class  StmtExprMutator
 Extend native TIRX mutation while preserving block iterator binders. More...
 
class  StmtExprMutatorWithAnalyzer
 
class  StmtExprVisitor
 Extend native TIRX traversal with schedulable block semantics. More...
 
class  StmtExprVisitorWithAnalyzer
 
class  StmtFunctor
 Extend TIRX statement dispatch with schedulable blocks. More...
 
class  StmtFunctor< R(const Stmt &, Args...)>
 
class  TensorIntrin
 Managed reference to TensorIntrinNode. More...
 
class  TensorIntrinNode
 Tensor intrinsics for tensorization. More...
 
class  Trace
 Managed reference to TraceNode. More...
 
class  TraceNode
 An execution trace of a scheduling program. More...
 

Typedefs

using FInstructionApply = ffi::TypedFunction< ffi::Array< Any >(Schedule sch, const ffi::Array< Any > &inputs, const ffi::Array< Any > &attrs, const Any &decision)>
 Type of the functor that applies the instruction to a TensorIR schedule.
 
using FInstructionAsPython = ffi::TypedFunction< ffi::String(const ffi::Array< Any > &inputs, const ffi::Array< Any > &attrs, const Any &decision, const ffi::Array< ffi::String > &outputs)>
 Type of the functor that converts the instruction to a statement in python syntax.
 
using FInstructionAttrsAsJSON = ffi::TypedFunction< ffi::ObjectRef(ffi::Array< Any > attrs)>
 Type of the functor that serialize its attributes to JSON.
 
using FInstructionAttrsFromJSON = ffi::TypedFunction< ffi::Array< Any >(ffi::ObjectRef json_attrs)>
 Type of the functor that deserialize its attributes from JSON.
 
using ExprRV = PrimExpr
 An expr random variable.
 
using ExprRVNode = ExprNode
 
using FTraceDecisionProvider = ffi::TypedFunction< Any(const Instruction &inst, const ffi::Array< Any > &inputs, const ffi::Array< Any > &attrs, const Any &decision)>
 A callback that allows users to mutate decisions on the fly when applying instructions. The signature of the callback is:
 
using TensorAllocatedAddresses = ffi::Array< ffi::Tuple< Var, ffi::Array< PrimExpr > > >
 Placement entries owned by a block, traversable with their tensor references.
 

Enumerations

enum  IterVarType : int {
  kDataPar = 0 , kThreadIndex = 1 , kCommReduce = 2 , kOrdered = 3 ,
  kOpaque = 4 , kUnrolled = 5 , kVectorized = 6 , kParallelized = 7 ,
  kTensorized = 8
}
 Type of iteration variable. Each IterVar have a specific type. More...
 
enum class  ScheduleErrorRenderLevel : int32_t { kDetail = 0 , kFast = 1 , kNone = 2 }
 The level of detailed error message rendering. More...
 
enum class  TensorIndexType : int32_t { kRead = 0 , kWrite = 1 }
 Type of tensor index. More...
 
enum  ScheduleDebugMask : uint32_t { kVerifySRefTree = 1 , kVerifyCachedFlags = 2 }
 The bitmask of the debug flag in the ScheduleStateObj. More...
 

Functions

bool VerifyWellFormed (const tirx::Function &func, bool assert_mode=true)
 Verify variable/tensor definitions, load types and schedulable block boundaries.
 
bool VerifyWellFormed (const IRModule &mod, bool assert_mode=true)
 Verify S-TIR or mixed modules, including definitions shared across functions.
 
double EstimateTIRFlops (const Stmt &stmt)
 Estimate the FLOPs of a TIR fragment.
 
double EstimateTIRFlops (const IRModule &mod)
 Estimate the FLOPs of TIRs in an IRModule.
 
bool IsPureFunction (const Function &func, bool assert_on_error=false)
 Analyze the side effect of a function.
 
bool VerifyGPUCode (const Function &func, ffi::Map< ffi::String, PrimExpr > constraints)
 Verify the correctness of a GPU code.
 
std::optional< MemCpyDetails > IdentifyMemCpy (const For &loop, const sym::Analyzer &analyzer)
 Identify whether a For loop is semantically equivalent to MemCpy.
 
ffi::Array< ffi::Optional< Range > > DomainTouched (const Stmt &body, const TensorVar &tensor, bool consider_loads, bool consider_stores)
 Infer the domain touched by tensor accesses within a statement.
 
ffi::Map< ffi::String, ffi::Map< ffi::String, int64_t > > CalculateAllocatedBytes (const Function &func)
 Calculate the allocated memory per scope in bytes needed inside the TIR Function.
 
ffi::Map< ffi::String, ffi::Map< ffi::String, int64_t > > CalculateAllocatedBytes (const IRModule &mod)
 Calculate the allocated memory per scope in bytes for each function inside the module.
 
ffi::Array< tvm::transform::Pass > GetVTCMCompactionPasses ()
 Get the list of lowering passes to calculate the compacted VTCM allocation size.
 
bool VerifyVTCMLimit (const IRModule &mod, int64_t limit)
 Verifies that the VTCM usage for all functions in the given IRModule.
 
bool VerifyVTCMLimit (const Function &func, int64_t limit)
 Verifies that the VTCM usage of the given function is within the provided limit.
 
const char * IterVarType2String (IterVarType t)
 
const Op & async_copy_scope ()
 Region marking copies eligible for asynchronous lowering.
 
const Op & async_commit ()
 Commit the preceding asynchronous copies to a queue.
 
const Op & async_wait ()
 Wait until at most the given number of committed groups remain in flight.
 
const Op & manual_sync ()
 Region whose author manages cross-thread synchronization explicitly.
 
ffi::Optional< ffi::String > GetThreadBinding (const ForNode *loop)
 Interpret and validate S-TIR thread placement on a shared loop.
 
ffi::Optional< ffi::String > GetThreadBinding (const For &loop)
 

Typedef Documentation

◆ ExprRV

using tvm::s_tir::ExprRV = typedef PrimExpr

An expr random variable.

◆ ExprRVNode

◆ FInstructionApply

using tvm::s_tir::FInstructionApply = typedef ffi::TypedFunction<ffi::Array<Any>(Schedule sch, const ffi::Array<Any>& inputs, const ffi::Array<Any>& attrs, const Any& decision)>

Type of the functor that applies the instruction to a TensorIR schedule.

Parameters
schThe schedule to be applied on
inputsThe input random variables
attrsInstruction attributes
decisionDecisions made on the instruction
Returns
The functor returns an array of output random variables

◆ FInstructionAsPython

using tvm::s_tir::FInstructionAsPython = typedef ffi::TypedFunction<ffi::String(const ffi::Array<Any>& inputs, const ffi::Array<Any>& attrs, const Any& decision, const ffi::Array<ffi::String>& outputs)>

Type of the functor that converts the instruction to a statement in python syntax.

Parameters
inputsNames of the input random variables
attrsInstruction attributes
decisionsDecisions made on the instruction
outputsNames of the output random variables
Returns
A string representing the python api call

◆ FInstructionAttrsAsJSON

using tvm::s_tir::FInstructionAttrsAsJSON = typedef ffi::TypedFunction<ffi::ObjectRef(ffi::Array<Any> attrs)>

Type of the functor that serialize its attributes to JSON.

Parameters
attrsThe attributes to be serialized
Returns
An array, serialized attributes
Note
This functor is nullable

◆ FInstructionAttrsFromJSON

using tvm::s_tir::FInstructionAttrsFromJSON = typedef ffi::TypedFunction<ffi::Array<Any>(ffi::ObjectRef json_attrs)>

Type of the functor that deserialize its attributes from JSON.

Parameters
json_attrsThe attributes to be serialized
Returns
An array, deserialized attributes
Note
This functor is nullable

◆ FTraceDecisionProvider

using tvm::s_tir::FTraceDecisionProvider = typedef ffi::TypedFunction<Any(const Instruction& inst, const ffi::Array<Any>& inputs, const ffi::Array<Any>& attrs, const Any& decision)>

A callback that allows users to mutate decisions on the fly when applying instructions. The signature of the callback is:

Parameters
instThe instruction
inputsThe input random variables
attrsThe attributes
decisionThe original decision
Returns
A new decision

◆ TensorAllocatedAddresses

using tvm::s_tir::TensorAllocatedAddresses = typedef ffi::Array<ffi::Tuple<Var, ffi::Array<PrimExpr> >>

Placement entries owned by a block, traversable with their tensor references.

Enumeration Type Documentation

◆ IterVarType

Type of iteration variable. Each IterVar have a specific type.

The type of iter var can be overriden via stage.iter_var_attrs given they are compatible.

Enumerator
kDataPar 

Data parallel iteration. This normally corresponds to axis of Tensor. Allow all IterVar manipulations.

Note
This does not mean the loop have to be executed in parallel fashion.
kThreadIndex 

The IterVar itself is a thread-index of a fixed thread launching group. Note that this is already assumed to be parallelized.

Disallow: split/fuse/vectorize/parallel

kCommReduce 

Communicative reduction. Cannot be directly parallelized.

Disallow: parallel/vectorize

kOrdered 

Serial loops with loop carry dependency, the iteration must execute in order. Cannot be re-ordered.

Disallow: reorder/parallel/vectorize

kOpaque 

IterVar is opaque,.

May not corresponds to any generated loop Disallow all IterVar manipulations and compute_at

Note
This is usually used to implement composite op or external op, where the
kUnrolled 

The execution is unrolled.

kVectorized 

The loop is vectorized.

kParallelized 

The loop is parallelized.

kTensorized 

Marks boundary of tensorization intrinsic.

◆ ScheduleDebugMask

The bitmask of the debug flag in the ScheduleStateObj.

See also
ScheduleStateObj
Enumerator
kVerifySRefTree 

Verify the correctness of the sref tree.

kVerifyCachedFlags 

Verify the correctness of affine_binding, region_cover and stage_pipeline.

◆ ScheduleErrorRenderLevel

enum class tvm::s_tir::ScheduleErrorRenderLevel : int32_t
strong

The level of detailed error message rendering.

Enumerator
kDetail 

Render a detailed error message.

kFast 

Render the error in fast mode.

kNone 

No error message at all.

◆ TensorIndexType

enum class tvm::s_tir::TensorIndexType : int32_t
strong

Type of tensor index.

Enumerator
kRead 

Index of a read tensor.

kWrite 

Index of a written tensor.

Function Documentation

◆ async_commit()

const Op & tvm::s_tir::async_commit ( )

Commit the preceding asynchronous copies to a queue.

◆ async_copy_scope()

const Op & tvm::s_tir::async_copy_scope ( )

Region marking copies eligible for asynchronous lowering.

◆ async_wait()

const Op & tvm::s_tir::async_wait ( )

Wait until at most the given number of committed groups remain in flight.

◆ CalculateAllocatedBytes() [1/2]

ffi::Map< ffi::String, ffi::Map< ffi::String, int64_t > > tvm::s_tir::CalculateAllocatedBytes ( const Function &  func)

Calculate the allocated memory per scope in bytes needed inside the TIR Function.

Parameters
funcThe TIR Function for which the allocated memory size to be calculated
Returns
Allocated memory size per scope in bytes.

◆ CalculateAllocatedBytes() [2/2]

ffi::Map< ffi::String, ffi::Map< ffi::String, int64_t > > tvm::s_tir::CalculateAllocatedBytes ( const IRModule &  mod)

Calculate the allocated memory per scope in bytes for each function inside the module.

Parameters
modThe IRModule for which the allocated memory size has to be calculated
Returns
Allocated memory size per scope in bytes for each function.

◆ DomainTouched()

ffi::Array< ffi::Optional< Range > > tvm::s_tir::DomainTouched ( const Stmt &  body,
const TensorVar &  tensor,
bool  consider_loads,
bool  consider_stores 
)

Infer the domain touched by tensor accesses within a statement.

Parameters
bodyThe statement to analyze.
tensorThe tensor whose accesses are analyzed.
consider_loadsWhether to include loads.
consider_storesWhether to include stores.
Returns
The domain covering the selected accesses.

◆ EstimateTIRFlops() [1/2]

double tvm::s_tir::EstimateTIRFlops ( const IRModule &  mod)

Estimate the FLOPs of TIRs in an IRModule.

Parameters
modThe IRModule to be estimated.
Returns
The estimated FLOPs.

◆ EstimateTIRFlops() [2/2]

double tvm::s_tir::EstimateTIRFlops ( const Stmt &  stmt)

Estimate the FLOPs of a TIR fragment.

Parameters
stmtThe TIR fragment to be estimated.
Returns
The estimated FLOPs.

◆ GetThreadBinding() [1/2]

ffi::Optional< ffi::String > tvm::s_tir::GetThreadBinding ( const For &  loop)
inline

◆ GetThreadBinding() [2/2]

ffi::Optional< ffi::String > tvm::s_tir::GetThreadBinding ( const ForNode *  loop)
inline

Interpret and validate S-TIR thread placement on a shared loop.

◆ GetVTCMCompactionPasses()

ffi::Array< tvm::transform::Pass > tvm::s_tir::GetVTCMCompactionPasses ( )

Get the list of lowering passes to calculate the compacted VTCM allocation size.

Returns
The list of passes.

◆ IdentifyMemCpy()

std::optional< MemCpyDetails > tvm::s_tir::IdentifyMemCpy ( const For &  loop,
const sym::Analyzer &  analyzer 
)

Identify whether a For loop is semantically equivalent to MemCpy.

Parameters
loopThe loop to be checked
analyzerThe analyzer with which to check any algebraic expressions
Returns
The source and destination regions being copied, if the loop is equivalent to memcpy.

◆ IsPureFunction()

bool tvm::s_tir::IsPureFunction ( const Function &  func,
bool  assert_on_error = false 
)

Analyze the side effect of a function.

Parameters
funcThe function to be checked.
assert_on_errorIf true, an error will be thrown for an impure function.
Returns
The purity of the function.

◆ IterVarType2String()

const char * tvm::s_tir::IterVarType2String ( IterVarType  t)
inline

◆ manual_sync()

const Op & tvm::s_tir::manual_sync ( )

Region whose author manages cross-thread synchronization explicitly.

◆ VerifyGPUCode()

bool tvm::s_tir::VerifyGPUCode ( const Function &  func,
ffi::Map< ffi::String, PrimExpr >  constraints 
)

Verify the correctness of a GPU code.

Parameters
funcThe function to be checked.
constraintsThe dict to specify constraints to check.
Returns
valid Whether it is a valid GPU code.

◆ VerifyVTCMLimit() [1/2]

bool tvm::s_tir::VerifyVTCMLimit ( const Function &  func,
int64_t  limit 
)

Verifies that the VTCM usage of the given function is within the provided limit.

Parameters
funcThe function to be checked.
limitThe limit to check.
Returns
true if the VTCM usage is within the provided limit.

◆ VerifyVTCMLimit() [2/2]

bool tvm::s_tir::VerifyVTCMLimit ( const IRModule &  mod,
int64_t  limit 
)

Verifies that the VTCM usage for all functions in the given IRModule.

Parameters
modThe module to be checked.
limitThe limit to check.
Returns
true if the VTCM usage is within the provided limit.

◆ VerifyWellFormed() [1/2]

bool tvm::s_tir::VerifyWellFormed ( const IRModule &  mod,
bool  assert_mode = true 
)

Verify S-TIR or mixed modules, including definitions shared across functions.

◆ VerifyWellFormed() [2/2]

bool tvm::s_tir::VerifyWellFormed ( const tirx::Function &  func,
bool  assert_mode = true 
)

Verify variable/tensor definitions, load types and schedulable block boundaries.