FreeTensor
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Enumerations | Functions | Variables
freetensor Namespace Reference

Namespaces

namespace  cpu
 
namespace  detail
 
namespace  gpu
 

Classes

struct  _Join
 
class  AbsNode
 
struct  AccessBound
 
struct  AccessPoint
 
struct  AccessPointBase
 
class  AddDimToVar
 
class  AddNode
 
class  AfterSelector
 
class  Allocator
 
class  AllocNode
 
class  AllUses
 
class  AnalyzeDeps
 
class  AnalyzeLinear
 
class  AnalyzeVersion
 
class  AncestorSelector
 
class  AnnotateConds
 
class  AnonymousMetadataContent
 
class  AnyExprNode
 
class  AnyNode
 
class  Array
 
struct  ArrayCopy
 
class  AsDNF
 
class  AsMatMul
 
class  AssertAlwaysFalse
 
class  AssertNode
 
class  AssumeNode
 
class  ASTNode
 
class  ASTParserBase
 
class  ASTPart
 
struct  AutoScheduleTuneTrial
 
class  BackUnroll
 
class  BeforeSelector
 
class  BinaryExprNode
 
class  BlendPass
 
class  BoolConstNode
 
class  BothMetadataSelector
 
class  BothSelector
 
class  Buffer
 
class  BuiltinSimplify
 
class  CallerSelector
 
class  CastNode
 
class  CeilDivNode
 
class  CeilNode
 
class  CheckFuseAccessible
 
class  CheckLoopOrder
 
class  CheckNameToDefMapping
 
class  CheckReadToParallelScopeMapping
 
class  CheckSideEffect
 
struct  ChildOf
 
class  ChildSelector
 
class  ClearDataType
 
class  ClearMarkVersion
 
class  CodeGen
 
class  CodeGenC
 
class  CodeGenCPU
 
struct  CodeGenStream
 
class  CommutativeBinaryExprNode
 
class  CompAccessBound
 
class  CompTransientBounds
 
class  CompTransientBoundsInterface
 
class  CompUniqueBounds
 
class  CompUniqueBoundsCombination
 
class  CompUniqueBoundsPB
 
class  Config
 
class  ConstFold
 
class  ConstNode
 
class  CosNode
 
class  CountContigAccessLoops
 
class  CountNames
 
class  CountScopeLen
 
class  CPUTarget
 
struct  CUDAScope
 
struct  CUDAStreamScope
 
struct  CutlassMicroKernelProperty
 
class  DataType
 
class  DataTypeInfer
 
class  DedupTapeNames
 
struct  Dependence
 
class  Derivative
 
class  DescendantSelector
 
class  Device
 
class  DirectAfterSelector
 
class  DirectBeforeSelector
 
class  DirectCallerSelector
 
struct  DiscreteObservation
 
class  DiscreteRandVar
 
class  DisjointSet
 
class  Driver
 
class  DriverError
 
class  EitherMetadataSelector
 
class  EitherSelector
 
class  EnableSelf
 
class  EnableSelfBase
 
class  EQNode
 
class  Error
 
class  EvalNode
 
class  ExpNode
 
class  ExprNode
 
class  FindAccessPoint
 
class  FindAllNoDeps
 
class  FindAllParallel
 
class  FindAllScopesInside
 
class  FindDeps
 
class  FindIndexingLoops
 
class  FindInnerMostScope
 
class  FindInvertibles
 
class  FindLoopInvariantWrites
 
class  FindLoopVariance
 
class  FindMemType
 
class  FindSerialLoopsOverReduce
 
class  FindSideEffectIntrinsics
 
class  FindStmtByFilter
 
class  FindStmtById
 
class  FissionFor
 
class  FlattenStmtSeq
 
class  FloatConstNode
 
class  FloatSimplify
 
class  FloorDivNode
 
class  FloorNode
 
class  ForNode
 
struct  ForProperty
 
class  FreeNode
 
class  FrontendVar
 
class  FrontendVarIdx
 
class  FuncNode
 
struct  FuncParam
 
struct  FuncRet
 
class  FuseFor
 
class  GENode
 
class  GenPBExpr
 
class  Grad
 
class  GTNode
 
class  HashComparator
 
class  Hasher
 
class  HoistReturnVars
 
class  HoistSelectedVar
 
class  HoistVarOverStmtSeq
 
class  ID
 
class  IDSelector
 
class  IfExprNode
 
class  IfNode
 
class  ImmediateUnroll
 
class  InitExprVari
 
class  InlinedInvoke
 
class  InsertAlloc
 
class  InsertFree
 
class  InsertTmpEval
 
class  InsertUserGrad
 
class  IntConstNode
 
class  InterruptExcept
 
class  IntrinsicNode
 
class  InvalidAutoGrad
 
class  InvalidIO
 
class  InvalidProgram
 
class  InvalidSchedule
 
struct  InversionInfo
 
class  InvertFromStore
 
struct  IterAxis
 
class  LabelSelector
 
class  LAndNode
 
class  Lazy
 
class  LeafNodeSelector
 
class  LENode
 
struct  LinearExpr
 
class  LnNode
 
class  LNotNode
 
class  LoadAtVersionNode
 
class  LoadNode
 
class  LogCtrl
 
class  Logger
 
struct  LoopInScopes
 
class  LOrNode
 
class  LowerBound
 
class  LTNode
 
class  MakeCacheVar
 
class  MakeFillAndFlush
 
class  MakeHeapAlloc
 
class  MakeInitAndReduce
 
class  MakeInline
 
class  MakeLoopCarriedReduction
 
class  MakeReduction
 
class  MakeSyncReduction
 
class  MarkStores
 
class  MarkVersionNode
 
class  MatchVisitor
 
class  MatMulNode
 
class  MaxNode
 
class  MemoizedSchedules
 
class  MergeAndHoistIf
 
class  MergeFor
 
class  MergeTapeInput
 
class  MessageBuilder
 
class  MetadataContent
 
class  MetadataSelector
 
class  MinNode
 
struct  ModifiedException
 
class  ModNode
 
class  MoveOutFirstOrLastIter
 
class  MulNode
 
class  Mutator
 
class  NativeCode
 
struct  NativeCodeParam
 
struct  NativeCodeRet
 
struct  NeedVarReorder
 
class  NENode
 
struct  NodeFeature
 
struct  NodeIDOrParallelScope
 
class  NodeTypeSelector
 
class  NonCommutativeBinaryExprNode
 
class  NormalizeLoops
 
class  NotMetadataSelector
 
class  NotSelector
 
class  OpenMPRandomEngine
 
struct  OpenMPScope
 
class  OutputIntermediates
 
struct  ParallelInfo
 
class  Parallelize
 
class  ParentSelector
 
class  ParserError
 
class  PBBuilder
 
class  PBBuildExpr
 
class  PBCtx
 
class  PBFunc
 
class  PBMap
 
class  PBMapBuilder
 
class  PBPoint
 
class  PBSet
 
class  PBSetBuilder
 
class  PBSimplify
 
class  PBSingleFunc
 
class  PBSpace
 
class  PBVal
 
class  Permute
 
class  PrintVisitor
 
struct  ProgramPositionHelper
 
class  PropagateProvides
 
class  PropagateRequires
 
class  PtrInvocable
 
class  RandCond
 
class  RandCondCRTP
 
class  RandCondGuard
 
class  RandCondInterface
 
class  RandCtx
 
class  RandCtxImpl
 
struct  RangeToUserGrad
 
struct  Rational
 
class  RealDivNode
 
class  ReduceToNode
 
struct  ReductionItem
 
class  Ref
 
class  RefineSignDataType
 
class  RemainderNode
 
class  RemoveAllWrites
 
class  RemoveDeadVar
 
class  RemoveWrites
 
class  RenameIter
 
class  RenameVar
 
class  RenewIDs
 
class  Reorder
 
class  ReplaceBySaved
 
class  ReplaceIter
 
class  ReplaceUses
 
class  RootCallSelector
 
class  RootNodeSelector
 
class  RoundTowards0DivNode
 
class  ScalarPropConst
 
struct  Scale
 
class  Schedule
 
class  ScheduleLogItem
 
struct  ScheduleLogItemEqual
 
struct  ScheduleLogItemHash
 
class  ScheduleLogItemImpl
 
class  Selector
 
class  SeparateTail
 
struct  SerialScope
 
class  SetMemType
 
class  SetUserVersionsForInputs
 
class  SharedLinkedList
 
class  ShrinkFor
 
class  ShrinkVar
 
class  SigmoidNode
 
struct  SimplePBFuncAST
 
class  SimplifyPass
 
class  SinkVar
 
class  SinNode
 
union  SmallItem
 
class  SmallItemAllocator
 
class  SmallItemBlock
 
class  SourceMetadataContent
 
class  Splitter
 
class  SqrtNode
 
class  SquareNode
 
struct  StaticInfo
 
class  StmtNode
 
class  StmtOrExprID
 
class  StmtSeqNode
 
struct  StmtSetToUserGrad
 
class  StoreNode
 
class  StripReturns
 
class  StructuralFeature
 
class  SubNode
 
class  SubTree
 
class  SubTreeList
 
class  Swap
 
class  SymbolNotFound
 
class  SymbolTable
 
class  SymbolTableData
 
class  SymbolTableInterface
 
class  SyncFunc
 
class  SyncFunc< R(Params...)>
 
class  TanhNode
 
class  TanNode
 
class  TapeStrategy
 
class  Target
 
class  Tensor
 
class  ThrowIndirectAccess
 
class  TrackStmt
 
class  TransformedMetadataContent
 
class  TransformedSelector
 
struct  TransientBound
 
struct  TypeOrMonostate
 
struct  TypeOrMonostate< void >
 
class  UnaryExprNode
 
class  UnboundNode
 
class  UndoMakeReduction
 
class  UnexpectedQueryResult
 
class  UpdateDType
 
class  UpperBound
 
class  UseBuiltinDiv
 
class  VarDefNode
 
class  VarMerge
 
class  VarNode
 
class  VarReorder
 
class  VarSplit
 
class  Vectorize
 
class  Visitor
 
class  Weak
 
class  WrapMetadata
 
class  Z3Simplify
 
class  Z3SimplifyWithSymbolTable
 

Concepts

concept  PBMapRef
 
concept  PBValRef
 
concept  PBSetRef
 
concept  PBSpaceRef
 
concept  PBFuncRef
 
concept  PBSingleFuncRef
 
concept  IntegralExceptBool
 
concept  HasStreamOutput
 

Typedefs

typedef std::vector< std::vector< Expr > > DNF
 
typedef int CompAccessBoundMode
 
typedef SyncFunc< bool(const AccessPointBase &)> FindDepsAccFilter
 
typedef std::function< bool(const AccessPoint &)> FindDepsAccPtFilter
 
typedef std::function< bool(const AccessPoint &later, const AccessPoint &earlier)> FindDepsFilter
 
typedef int DepType
 
typedef std::vector< std::pair< NodeIDOrParallelScope, DepDirection > > FindDepsDir
 
typedef SyncFunc< void(const Dependence &)> FindDepsCallback
 
typedef std::unordered_map< std::string, std::unordered_map< ID, LoopVariability > > LoopVariTransVarMap
 
typedef std::unordered_map< ID, std::unordered_map< ID, LoopVariability > > LoopVariUniqVarMap
 
typedef std::unordered_map< StmtOrExprID, std::unordered_map< ID, LoopVariability > > LoopVariExprMap
 
typedef Ref< ASTNodeAST
 
typedef Ref< StmtNodeStmt
 
typedef Ref< ExprNodeExpr
 
typedef Ref< AnyExprNodeAnyExpr
 
typedef Ref< VarNodeVar
 
typedef Ref< LoadNodeLoad
 
typedef Ref< ConstNodeConst
 
typedef Ref< IntConstNodeIntConst
 
typedef Ref< FloatConstNodeFloatConst
 
typedef Ref< BoolConstNodeBoolConst
 
typedef Ref< BinaryExprNodeBinaryExpr
 
typedef Ref< CommutativeBinaryExprNodeCommutativeBinaryExpr
 
typedef Ref< NonCommutativeBinaryExprNodeNonCommutativeBinaryExpr
 
typedef Ref< AddNodeAdd
 
typedef Ref< SubNodeSub
 
typedef Ref< MulNodeMul
 
typedef Ref< RealDivNodeRealDiv
 
typedef Ref< FloorDivNodeFloorDiv
 
typedef Ref< CeilDivNodeCeilDiv
 
typedef Ref< RoundTowards0DivNodeRoundTowards0Div
 
typedef Ref< ModNodeMod
 
typedef Ref< RemainderNodeRemainder
 
typedef Ref< MinNodeMin
 
typedef Ref< MaxNodeMax
 
typedef Ref< LTNodeLT
 
typedef Ref< LENodeLE
 
typedef Ref< GTNodeGT
 
typedef Ref< GENodeGE
 
typedef Ref< EQNodeEQ
 
typedef Ref< NENodeNE
 
typedef Ref< LAndNodeLAnd
 
typedef Ref< LOrNodeLOr
 
typedef Ref< UnaryExprNodeUnaryExpr
 
typedef Ref< LNotNodeLNot
 
typedef Ref< SqrtNodeSqrt
 
typedef Ref< ExpNodeExp
 
typedef Ref< LnNodeLn
 
typedef Ref< SquareNodeSquare
 
typedef Ref< SigmoidNodeSigmoid
 
typedef Ref< SinNodeSin
 
typedef Ref< CosNodeCos
 
typedef Ref< TanNodeTan
 
typedef Ref< TanhNodeTanh
 
typedef Ref< AbsNodeAbs
 
typedef Ref< FloorNodeFloor
 
typedef Ref< CeilNodeCeil
 
typedef Ref< UnboundNodeUnbound
 
typedef Ref< IfExprNodeIfExpr
 
typedef Ref< CastNodeCast
 
typedef Ref< IntrinsicNodeIntrinsic
 
typedef Ref< LoadAtVersionNodeLoadAtVersion
 
typedef Ref< FuncNodeFunc
 
template<class K , class V >
using ASTHashMap = std::unordered_map< K, V, Hasher, HashComparator >
 
template<class K >
using ASTHashSet = std::unordered_set< K, Hasher, HashComparator >
 
typedef std::vector< SimplePBFuncASTPBFuncAST
 
using Metadata = Ref< MetadataContent >
 
using MetadataHasher = PtrInvocable< std::hash< MetadataContent > >
 
using MetadataComparator = PtrInvocable< std::equal_to< MetadataContent > >
 
using TransformedMetadata = Ref< TransformedMetadataContent >
 
using SourceMetadata = Ref< SourceMetadataContent >
 
using AnonymousMetadata = Ref< AnonymousMetadataContent >
 
typedef std::variant< SerialScope, OpenMPScope, CUDAStreamScope, CUDAScopeParallelScope
 
typedef SharedLinkedList< Ref< RandCondInterface > > RandCondStack
 
typedef const ProgramPositionHelperProgramPosition
 
typedef std::vector< DiscreteObservationRandTrace
 
using IDMetadataPack = std::pair< ID, Metadata >
 
typedef SharedLinkedList< Ref< ScheduleLogItem >, ScheduleLogItemHash, ScheduleLogItemEqualScheduleLog
 
typedef Ref< AnyNodeAny
 
typedef Ref< StmtSeqNodeStmtSeq
 
typedef Ref< VarDefNodeVarDef
 
typedef Ref< StoreNodeStore
 
typedef Ref< AllocNodeAlloc
 
typedef Ref< FreeNodeFree
 
typedef Ref< ReduceToNodeReduceTo
 
typedef Ref< ForNodeFor
 
typedef Ref< IfNodeIf
 
typedef Ref< AssertNodeAssert
 
typedef Ref< AssumeNodeAssume
 
typedef Ref< EvalNodeEval
 
typedef Ref< MatMulNodeMatMul
 
typedef Ref< MarkVersionNodeMarkVersion
 

Enumerations

enum class  CheckNotModifiedSide : int { Before , After }
 
enum class  DepDirection : int { Normal , Inv , Same , Different }
 
enum class  FindDepsMode : int { Dep , KillEarlier , KillLater , KillBoth }
 
enum class  LoopVariability : int { Unknown , Variant }
 
enum class  ASTNodeType : int {
  Any , AnyExpr , Func , Store ,
  ReduceTo , Load , Alloc , Free ,
  StmtSeq , VarDef , For , If ,
  Assert , Assume , MatMul , Eval ,
  Var , IntConst , FloatConst , BoolConst ,
  Add , Sub , Mul , RealDiv ,
  FloorDiv , CeilDiv , RoundTowards0Div , Mod ,
  Remainder , Min , Max , LT ,
  LE , GT , GE , EQ ,
  NE , LAnd , LOr , LNot ,
  Sqrt , Exp , Ln , Square ,
  Sigmoid , Sin , Cos , Tan ,
  Tanh , Abs , Floor , Ceil ,
  Unbound , IfExpr , Cast , Intrinsic ,
  MarkVersion , LoadAtVersion
}
 
enum class  OutputIntermediatesStage : int { Forward , Backward }
 
enum class  GradTapeMode : int { All , Nothing , NoReuseOnly }
 
enum class  TargetType : int { CPU , GPU }
 
enum class  FrontendVarIdxType : int { Single , Slice }
 
enum class  MetadataType { Transformed , Source , Anonymous }
 
enum class  ReduceOp : int {
  Add , Mul , Min , Max ,
  LAnd , LOr
}
 
enum class  MoveToSide : int { Before , After }
 
enum class  AsMatMulMode : int { KeepMemLayout , TryVarReorder , TryTranspose }
 
enum class  FissionSide : int { Before , After }
 
enum class  FindLoopInScopesDirection : int { Front , Back }
 
enum class  ReorderMode : int { PerfectOnly , MoveOutImperfect , MoveInImperfect }
 
enum class  ScheduleType : int {
  Split = 0 , Reorder , Merge , Fission ,
  Fuse , Swap , Blend , Cache ,
  CacheReduction , SetMemType , VarSplit , VarMerge ,
  VarReorder , VarUnsqueeze , VarSqueeze , Inline ,
  Parallelize , ParallelizeAs , Unroll , Vectorize ,
  SeparateTail , AsMatMul , Permute , PlutoFuse ,
  PlutoPermute , NumTypes
}
 
enum  VarSplitMode : int { FixedSize , RelaxedSize }
 
enum class  MatMulBackend : size_t {
  Mkl = 0 , Cublas , Cutlass , CutlassMicroBlock ,
  CutlassMicroThread , NumBackends
}
 
enum  NullPolicy : int { NotNull , Nullable }
 
enum class  AccessType : size_t {
  Input = 0 , Bypass , Cache , Output ,
  InputMutable , InOut , NumTypes
}
 
enum class  BaseDataType : size_t {
  Void = 0 , Float16 , Float32 , Float64 ,
  Int32 , Int64 , Bool , Custom ,
  Never , NumTypes
}
 
enum class  SignDataType : size_t {
  Any = 0 , GT0 , GE0 , LT0 ,
  LE0 , NE0 , EQ0 , Never ,
  NumTypes
}
 
enum class  MemType : size_t {
  ByValue = 0 , CPU , GPUGlobal , GPUShared ,
  GPULocal , GPUWarp , CPUHeap , GPUGlobalHeap ,
  NumTypes
}
 

Functions

template<class T >
bool operator== (const Allocator< T > &lhs, const Allocator< T > &rhs)
 
std::vector< std::pair< ID, std::string > > allDefs (const Stmt &op, const std::unordered_set< AccessType > &atypes=allAccessTypes|ranges::to< std::unordered_set >())
 
template<typename T >
std::unordered_set< IntrinsicallSideEffectIntrinsics (T &&op)
 
LinearExpr< int64_t > linear (const Expr &expr)
 
std::optional< std::pair< LinearExpr< int64_t >, ASTNodeType > > linearComp (const Expr &expr)
 
DNF asDNF (const Expr &expr)
 
bool checkAllDefined (const std::unordered_set< std::string > &defs, const std::unordered_set< std::string > &namesInOp)
 
bool checkAllDefined (const std::unordered_set< std::string > &defs, const AST &op)
 
bool checkNotModified (const Stmt &op, const Expr &expr, CheckNotModifiedSide s0Side, const ID &s0, CheckNotModifiedSide s1Side, const ID &s1)
 
bool checkNotModified (const Stmt &op, const Expr &s0Expr, const Expr &s1Expr, CheckNotModifiedSide s0Side, const ID &s0, CheckNotModifiedSide s1Side, const ID &s1)
 
AccessBound compAccessBound (const Stmt &op, const ID &varDefId, CompAccessBoundMode mode=COMP_ACCESS_BOUND_ALL, bool includeTrivialBound=true, const ID &filterSubTree=ID())
 
std::ostream & operator<< (std::ostream &os, const Dependence &dep)
 
std::unordered_map< For, std::vector< VarDef > > findIndexingLoops (const Stmt &op)
 
bool isVariant (const LoopVariExprMap &exprInfo, const StmtOrExprID &expr, const ID &loop)
 
bool isVariant (const LoopVariUniqVarMap &varInfo, const VarDef &def, const ID &loop)
 
bool isVariant (const LoopVariUniqVarMap &varInfo, const ID &defId, const ID &loop)
 
std::pair< LoopVariExprMap, LoopVariUniqVarMapfindLoopVariance (const Stmt &op)
 
std::vector< std::string > mergeNoDepsHint (const Stmt &ast, const std::vector< ID > &loops)
 
std::vector< std::string > mergeNoDepsHint (const Stmt &ast, const ID &loop1, const ID &loop2)
 
std::vector< std::pair< Expr, Expr > > normalizeConditionalExpr (const Expr &expr)
 
std::vector< std::pair< std::vector< Expr >, Expr > > normalizeConditionalExprList (const std::vector< Expr > &exprs)
 
std::unordered_map< ID, NodeFeaturestructuralFeature (const Stmt &op)
 
std::ostream & operator<< (std::ostream &os, ASTNodeType type)
 
Expr deepCopy (const Expr &op)
 
Stmt deepCopy (const Stmt &op)
 
AST lcaAST (const AST &lhs, const AST &rhs)
 
Expr lcaExpr (const Expr &lhs, const Expr &rhs)
 
Stmt lcaStmt (const Stmt &lhs, const Stmt &rhs)
 
template<typename... Srcs>
requires (std::convertible_to<Srcs, Stmt> && ...)
auto makeMetadata (const std::string &op, Srcs &&...sourceStmts)
 
std::vector< IDallNoReuseDefs (const Stmt &op, const std::unordered_set< AccessType > &atypes)
 
std::tuple< std::unordered_map< StmtOrExprID, Expr >, std::unordered_map< ID, Expr >, std::unordered_set< ID >, std::unordered_map< std::string, std::pair< std::string, Expr > > > analyzeVersion (const Stmt &op, const std::unordered_map< ID, std::unordered_set< ID > > &needVersions, const std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &derivatives, bool localVersionsOnly)
 
Stmt clearMarkVersion (const Stmt &op)
 
Stmt dedupTapeNames (const Stmt &op, const std::unordered_set< ID > &tapes)
 
std::pair< std::unordered_map< ID, std::unordered_set< ID > >, std::unordered_map< ID, std::unordered_set< ID > > > findTapeOrRecompStmts (const Stmt &op, const std::unordered_set< ID > &defsToTape, const std::unordered_set< ID > defsNeedGrad, std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &derivatives)
 
std::tuple< Stmt, std::unordered_map< ID, InversionInfo > > invertStmts (const Stmt &op, std::unordered_map< ID, std::unordered_set< ID > > *idsNeeded, std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > *derivatives)
 
Stmt mergeTapeInput (const Stmt &op)
 
std::tuple< Stmt, std::unordered_map< ID, std::string >, std::unordered_map< StmtOrExprID, Expr >, std::unordered_map< ID, Expr >, std::unordered_set< ID >, std::unordered_map< std::string, std::pair< std::string, Expr > > > outputIntermediates (const Stmt &op, const std::unordered_map< ID, std::unordered_set< ID > > &needVersions, const std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &derivatives, OutputIntermediatesStage stage=OutputIntermediatesStage::Forward, const std::string &varSuffix=".tape")
 
Stmt outputAllIntermedaites (const Stmt &op, const std::unordered_set< ID > &intermediates, OutputIntermediatesStage stage=OutputIntermediatesStage::Forward, const std::string &varSuffix=".tape")
 
std::unordered_set< IDpropagateDefsNeedGrad (const Stmt &op, const std::unordered_set< std::string > &_requires, const std::unordered_set< std::string > &provides)
 
std::optional< std::pair< ID, ID > > getRangeFromStmtSeq (const Stmt &op, const std::unordered_set< ID > &stmts)
 
template<class T >
Ref< BuffermakeBuffer (T &&tensor, AccessType atype, MemType mtype)
 
Ref< BufferdeepCopy (const Ref< Buffer > &b)
 
NativeCode codeGen (const Func &func, const Ref< Target > &target)
 
NativeCode codeGenCPU (const Func &func, const Ref< Target > &target)
 
std::ostream & operator<< (std::ostream &os, const NativeCodeParam &p)
 
std::ostream & operator<< (std::ostream &os, const NativeCodeRet &r)
 
template<class T , class V1 , class V2 , class Hash , class KeyEqual >
std::unordered_map< T, std::pair< V1, V2 >, Hash, KeyEqual > intersect (const std::unordered_map< T, V1, Hash, KeyEqual > &lhs, const std::unordered_map< T, V2, Hash, KeyEqual > &rhs)
 
template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > intersect (const std::unordered_set< T, Hash, KeyEqual > &lhs, const std::unordered_set< T, Hash, KeyEqual > &rhs)
 
template<class T , class Hash , class KeyEqual >
bool hasIntersect (const std::unordered_set< T, Hash, KeyEqual > &lhs, const std::unordered_set< T, Hash, KeyEqual > &rhs)
 
template<class T >
std::vector< T > intersect (const std::vector< T > &lhs, const std::vector< T > &rhs)
 
template<class T , class Hash , class KeyEqual >
bool isSubSetOf (const std::unordered_set< T, Hash, KeyEqual > &lhs, const std::unordered_set< T, Hash, KeyEqual > &rhs)
 
template<class T >
std::vector< T > uni (const std::vector< T > &lhs, const std::vector< T > &rhs)
 
template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > uni (const std::unordered_set< T, Hash, KeyEqual > &lhs, const std::unordered_set< T, Hash, KeyEqual > &rhs)
 
template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > diff (const std::unordered_set< T, Hash, KeyEqual > &lhs, const std::unordered_set< T, Hash, KeyEqual > &rhs)
 
template<class T >
std::vector< T > cat (const std::vector< T > &lhs, const std::vector< T > &rhs)
 
template<class T , class U >
std::vector< T > filter (const std::vector< T > &vec, const U &callback)
 
std::string tolower (const std::string &s)
 
std::string slice (const std::string &s, int begin, int end)
 
std::string slice (const std::string &s, int begin)
 
template<class T >
requires std::ranges::range<T> && (!std::convertible_to<T, std::string>)
std::ostream & operator<< (std::ostream &os, const T &r)
 
template<typename... Ts>
std::ostream & operator<< (std::ostream &os, std::tuple< Ts... > const &tuple)
 
template<std::ranges::range Container>
std::string join (Container &&c, const std::string &splitter)
 
auto join (const std::string &splitter)
 
template<std::ranges::range Container>
auto operator| (Container &&c, const _Join &joiner)
 
Ref< CutlassMicroKernelPropertydeepCopy (const Ref< CutlassMicroKernelProperty > &p)
 
std::ostream & operator<< (std::ostream &os, const AST &op)
 
bool match (const Stmt &pattern, const Stmt &instance)
 
void checkConflictId (const Stmt &ast)
 
void checkConflictId (const Func &func)
 
Logger logger ()
 
bool isSameTarget (const Ref< Target > &lhs, const Ref< Target > &rhs)
 
std::ostream & operator<< (std::ostream &os, const Ref< Target > &target)
 
void reportWarning (const std::string &msg)
 
Expr makeAnyExpr (std::source_location loc=std::source_location::current())
 
Expr makeVar (const std::string &name, std::source_location loc=std::source_location::current())
 
template<class Tindices >
Expr makeLoad (const std::string &var, Tindices &&indices, DataType loadType, std::source_location loc=std::source_location::current())
 
Expr makeLoad (const std::string &var, const std::vector< Expr > &indices, DataType loadType, std::source_location loc=std::source_location::current())
 
Expr makeIntConst (int64_t val, std::source_location loc=std::source_location::current())
 
Expr makeFloatConst (double val, std::source_location loc=std::source_location::current())
 
Expr makeBoolConst (bool val, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeAdd (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeSub (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeMul (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeRealDiv (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeFloorDiv (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeCeilDiv (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeRoundTowards0Div (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeMod (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeRemainder (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeMin (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeMax (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeLT (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeLE (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeGT (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeGE (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeEQ (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeNE (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeLAnd (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeLOr (T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeLNot (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeSqrt (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeExp (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeLn (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeSquare (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeSigmoid (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeSin (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeCos (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeTan (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeTanh (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeAbs (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeFloor (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeCeil (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeUnbound (T &&expr, std::source_location loc=std::source_location::current())
 
template<class T , class U , class V >
Expr makeIfExpr (T &&cond, U &&thenCase, V &&elseCase, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeCast (T &&expr, DataType destType, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeIntrinsic (const std::string &format, T &&params, DataType retType, bool hasSideEffect, std::source_location loc=std::source_location::current())
 
Expr makeIntrinsic (const std::string &format, std::initializer_list< Expr > params, DataType retType, bool hasSideEffect, std::source_location loc=std::source_location::current())
 
template<class Tindices >
Expr makeLoadAtVersion (const std::string &tapeName, Tindices &&indices, const DataType loadType, std::source_location loc=std::source_location::current())
 
Expr makeLoadAtVersion (const std::string &tapeName, const std::vector< Expr > &indices, const DataType loadType, std::source_location loc=std::source_location::current())
 
template<class T , class U >
Expr makeBinary (ASTNodeType nodeType, T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
 
template<class T >
Expr makeUnary (ASTNodeType nodeType, T &&expr, std::source_location loc=std::source_location::current())
 
template<class Tbegins , class Tends >
Ref< ReductionItemmakeReductionItem (ReduceOp op, const std::string &var, Tbegins &&begins, Tends &&ends, bool syncFlush)
 
Ref< ReductionItemdeepCopy (const Ref< ReductionItem > &r)
 
Ref< ForPropertydeepCopy (const Ref< ForProperty > &_p)
 
std::ostream & operator<< (std::ostream &os, const FrontendVarIdx &idx)
 
std::ostream & operator<< (std::ostream &os, const FrontendVar &var)
 
std::unordered_set< std::string > allReads (const FrontendVarIdx &idx)
 
std::pair< Func, std::vector< std::pair< int, Ref< Buffer > > > > stripReturns (const Func &func)
 
Stmt inlinedInvoke (const Metadata &callSiteMetadata, const Func &func, const std::vector< Ref< FrontendVar > > &args, const std::unordered_map< std::string, Ref< FrontendVar > > &kvs, const std::vector< std::string > &retNames, const std::unordered_set< std::string > &conflictNames, bool forceAllowClosures=false)
 
std::ostream & operator<< (std::ostream &os, const FuncParam &p)
 
std::ostream & operator<< (std::ostream &os, const FuncRet &r)
 
template<class Tbody , class Tparams , class Treturns , class Tclosure >
Func makeFunc (const std::string &name, Tparams &&params, Treturns &&returns, Tbody &&body)
 
template<class Tbody >
Func makeFunc (const std::string &name, const std::vector< FuncParam > &params, const std::vector< FuncRet > &returns, Tbody &&body)
 
Func deepCopy (const Func &func)
 
std::string getNewName (const std::string &oldName, const std::unordered_set< std::string > &used)
 
template<class K , class V >
bool operator== (const ASTHashMap< K, V > &lhs, const ASTHashMap< K, V > &rhs)
 
template<class K >
bool operator== (const ASTHashSet< K > &lhs, const ASTHashSet< K > &rhs)
 
size_t hashCombine (size_t seed, size_t other)
 
std::ostream & operator<< (std::ostream &os, const ID &id)
 
template<typename F >
 Lazy (F delayedInit) -> Lazy< std::decay_t< decltype(std::declval< F >()())> >
 
template<class T >
lower (const T &_ast, const Ref< Target > &_target=nullptr, const std::unordered_set< std::string > &skipPasses={}, int verbose=0)
 
UpperBound add (const UpperBound &b1, const UpperBound &b2)
 
LowerBound add (const LowerBound &b1, const LowerBound &b2)
 
UpperBound sub (const UpperBound &b1, const LowerBound &b2)
 
LowerBound sub (const LowerBound &b1, const UpperBound &b2)
 
UpperBound mul (const UpperBound &b, int k)
 
LowerBound mul (const LowerBound &b, int k)
 
UpperBound floorDiv (const UpperBound &b, int k)
 
LowerBound floorDiv (const LowerBound &b, int k)
 
UpperBound ceilDiv (const UpperBound &b, int k)
 
LowerBound ceilDiv (const LowerBound &b, int k)
 
bool alwaysLT (const UpperBound &b1, const LowerBound &b2)
 
bool alwaysLE (const UpperBound &b1, const LowerBound &b2)
 
template<class T >
std::pair< std::optional< LowerBound >, std::optional< UpperBound > > lin2bounds (const LinearExpr< T > &_lin, ASTNodeType cmp, const Expr &x)
 
template<class T >
LinearExpr< T > add (const LinearExpr< T > &lhs, const LinearExpr< T > &rhs)
 
template<class T >
LinearExpr< T > sub (const LinearExpr< T > &lhs, const LinearExpr< T > &rhs)
 
template<class T >
LinearExpr< T > mul (const LinearExpr< T > &lin, const T &k)
 
template<class T >
bool hasIdenticalCoeff (const LinearExpr< T > &lhs, const LinearExpr< T > &rhs)
 
template<class T >
requires std::integral<T> || std::floating_point<T>
Expr lin2expr (const LinearExpr< T > &lin)
 
template<class T >
bool operator== (const LinearExpr< T > &lhs, const LinearExpr< T > &rhs)
 
template<class T >
std::ostream & operator<< (std::ostream &os, const LinearExpr< T > &lin)
 
Expr makeMinMaxImpl (const std::vector< std::vector< Expr > > &exprs, const std::function< Expr()> &inf, const std::function< Expr()> &negInf)
 
Expr makeMaxMinImpl (const std::vector< std::vector< Expr > > &exprs, const std::function< Expr()> &inf, const std::function< Expr()> &negInf)
 
std::function< Expr()> asExprGenerator (std::nullptr_t)
 
std::function< Expr()> asExprGenerator (const std::function< Expr()> &e)
 
std::function< Expr()> asExprGenerator (const Expr &e)
 
template<typename T , typename U >
Expr makeMinMax (const std::vector< std::vector< Expr > > &exprs, const T &inf, const U &negInf)
 
template<typename T , typename U >
Expr makeMaxMin (const std::vector< std::vector< Expr > > &exprs, const T &negInf, const U &inf)
 
Expr makeLOrLAnd (const std::vector< std::vector< Expr > > &exprs)
 
std::ostream & operator<< (std::ostream &os, const SimplePBFuncAST &ast)
 
template<class T >
T * GET_ISL_PTR (T *ptr)
 
template<class T >
T * _COPY_ISL_PTR (const T *ptr, T *(copy)(T *))
 
template<class T >
T * MOVE_ISL_PTR (T *&ptr)
 
template<typename T >
auto PBRefTake (std::remove_reference_t< T > &t)
 
template<typename T >
auto PBRefTake (std::remove_reference_t< T > &&t)
 
Ref< PBCtxcommonCtx (const auto &lhs, const auto &rhs)
 
template<PBSetRef T>
PBSet projectOutAllParams (T &&set)
 
template<PBMapRef T>
PBMap projectOutAllParams (T &&map)
 
template<PBSetRef T>
PBSet projectOutParamById (T &&set, const std::string &name)
 
template<PBSetRef T>
PBSet projectOutParamDims (T &&set, unsigned first, unsigned n)
 
template<PBSetRef T>
PBSet projectOutDims (T &&set, unsigned first, unsigned n)
 
template<PBMapRef T>
PBMap projectOutParamById (T &&map, const std::string &name)
 
template<PBMapRef T>
PBMap projectOutParamDims (T &&map, unsigned first, unsigned n)
 
template<PBMapRef T>
PBMap projectOutInputDims (T &&map, unsigned first, unsigned n)
 
template<PBMapRef T>
PBMap projectOutOutputDims (T &&map, unsigned first, unsigned n)
 
template<PBSetRef T>
PBSet insertDims (T &&set, unsigned first, unsigned n)
 
template<PBMapRef T>
PBMap insertInputDims (T &&map, unsigned first, unsigned n)
 
template<PBMapRef T>
PBMap insertOutputDims (T &&map, unsigned first, unsigned n)
 
template<PBSetRef T>
PBSet fixDim (T &&set, unsigned pos, int x)
 
template<PBMapRef T>
PBMap fixInputDim (T &&map, unsigned pos, int x)
 
template<PBMapRef T>
PBMap fixOutputDim (T &&map, unsigned pos, int x)
 
template<PBSetRef T>
PBSet lowerBoundDim (T &&set, unsigned pos, int x)
 
template<PBMapRef T>
PBMap lowerBoundInputDim (T &&map, unsigned pos, int x)
 
template<PBMapRef T>
PBMap lowerBoundOutputDim (T &&map, unsigned pos, int x)
 
template<PBSetRef T>
PBSet upperBoundDim (T &&set, unsigned pos, int x)
 
template<PBMapRef T>
PBMap upperBoundInputDim (T &&map, unsigned pos, int x)
 
template<PBMapRef T>
PBMap upperBoundOutputDim (T &&map, unsigned pos, int x)
 
template<PBSetRef T>
PBMap newDomainOnlyMap (T &&set)
 
template<PBSetRef T>
PBMap newRangeOnlyMap (T &&set)
 
template<PBMapRef T>
PBMap moveDimsInputToOutput (T &&map, unsigned first, unsigned n, unsigned target)
 
template<PBMapRef T>
PBMap moveDimsOutputToInput (T &&map, unsigned first, unsigned n, unsigned target)
 
template<PBMapRef T>
PBMap moveDimsParamToInput (T &&map, unsigned first, unsigned n, unsigned target)
 
template<PBMapRef T>
PBMap moveDimsParamToOutput (T &&map, unsigned first, unsigned n, unsigned target)
 
template<PBSetRef T>
PBSet moveDimsSetToParam (T &&set, unsigned first, unsigned n, unsigned target)
 
template<PBSetRef T>
PBSet moveDimsParamToSet (T &&set, unsigned first, unsigned n, unsigned target)
 
template<PBSetRef T, PBSetRef U>
std::pair< PBSet, PBSetpadToSameDims (T &&lhs, U &&rhs)
 
template<PBSetRef T>
PBSet complement (T &&set)
 
template<PBMapRef T>
PBMap complement (T &&map)
 
template<PBMapRef T>
PBMap reverse (T &&map)
 
template<PBMapRef T, PBMapRef U>
PBMap subtract (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBSetRef U>
PBSet subtract (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBMapRef U>
PBMap intersect (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBSetRef U>
PBSet intersect (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBSetRef U>
PBMap intersectDomain (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBSetRef U>
PBMap intersectRange (T &&lhs, U &&rhs)
 
template<PBSingleFuncRef T, PBSetRef U>
PBSingleFunc intersectDomain (T &&lhs, U &&rhs)
 
template<PBFuncRef T, PBSetRef U>
PBFunc intersectDomain (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBSetRef U>
PBSet intersectParams (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBSetRef U>
PBMap intersectParams (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBMapRef U>
PBMap uni (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBSetRef U>
PBSet uni (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBMapRef U>
PBSet apply (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBMapRef U>
PBMap applyDomain (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBMapRef U>
PBMap applyRange (T &&lhs, U &&rhs)
 
template<PBMapRef T, PBMapRef U>
PBMap sum (T &&lhs, U &&rhs)
 
template<PBSetRef T, PBSetRef U>
PBSet sum (T &&lhs, U &&rhs)
 
template<PBMapRef T>
PBMap neg (T &&map)
 
template<PBSetRef T>
PBSet neg (T &&set)
 
template<PBMapRef T>
PBMap lexmax (T &&map)
 
template<PBMapRef T>
PBMap lexmin (T &&map)
 
template<PBSetRef T>
PBSet lexmax (T &&set)
 
template<PBSetRef T>
PBSet lexmin (T &&set)
 
template<PBSpaceRef T>
PBMap identity (T &&space)
 
template<PBSpaceRef T>
PBMap lexGE (T &&space)
 
template<PBSpaceRef T>
PBMap lexGT (T &&space)
 
template<PBSpaceRef T>
PBMap lexLE (T &&space)
 
template<PBSpaceRef T>
PBMap lexLT (T &&space)
 
PBSpace spaceAlloc (const Ref< PBCtx > &ctx, unsigned nparam, unsigned nIn, unsigned nOut)
 
PBSpace spaceSetAlloc (const Ref< PBCtx > &ctx, unsigned nparam, unsigned dim)
 
template<PBSpaceRef T>
PBSet emptySet (T &&space)
 
template<PBSpaceRef T>
PBMap emptyMap (T &&space)
 
template<PBSpaceRef T>
PBSet universeSet (T &&space)
 
template<PBSpaceRef T>
PBMap universeMap (T &&space)
 
template<PBMapRef T>
PBSet domain (T &&map)
 
template<PBMapRef T>
PBSet range (T &&map)
 
template<PBSetRef T>
PBSet params (T &&set)
 
template<PBSetRef T>
PBSet coalesce (T &&set)
 
template<PBMapRef T>
PBMap coalesce (T &&map)
 
template<PBSetRef T, PBSetRef U>
PBSet cartesianProduct (T &&lhs, U &&rhs)
 
template<PBSetRef T>
PBVal dimMaxVal (T &&set, int pos)
 
template<PBSetRef T>
PBVal dimMinVal (T &&set, int pos)
 
PBVal dimFixVal (const PBSet &set, int pos)
 
template<PBSpaceRef T>
PBSpace spaceMapFromSet (T &&space)
 
template<PBMapRef T>
PBSet wrap (T &&map)
 
template<PBSetRef T>
PBMap unwrap (T &&set)
 
template<PBSetRef T>
PBSet flatten (T &&set)
 
template<PBMapRef T>
PBMap flattenDomain (T &&map)
 
template<PBMapRef T>
PBMap flattenRange (T &&map)
 
template<PBMapRef T>
PBSet flattenMapToSet (T &&map)
 
template<PBSetRef T>
PBPoint sample (T &&set)
 
template<PBSingleFuncRef T, PBSingleFuncRef U>
PBSingleFunc min (T &&lhs, U &&rhs)
 
template<PBSingleFuncRef T, PBSingleFuncRef U>
PBSingleFunc max (T &&lhs, U &&rhs)
 
template<PBSetRef T>
PBSet coefficients (T &&set, int64_t c=0)
 
bool isSubset (const PBSet &small, const PBSet &big)
 
bool isSubset (const PBMap &small, const PBMap &big)
 
bool operator== (const PBSet &lhs, const PBSet &rhs)
 
bool operator== (const PBMap &lhs, const PBMap &rhs)
 
bool operator== (const PBSingleFunc &lhs, const PBSingleFunc &rhs)
 
bool operator== (const PBFunc &lhs, const PBFunc &rhs)
 
auto pbFuncWithTimeout (const auto &func, int seconds, const auto &...args) -> std::optional< decltype(func(args...))>
 
auto floorDiv (IntegralExceptBool auto a, IntegralExceptBool auto b)
 
auto ceilDiv (IntegralExceptBool auto a, IntegralExceptBool auto b)
 
auto mod (IntegralExceptBool auto a, IntegralExceptBool auto b)
 
template<class T >
square (T x)
 
bool square (bool x)
 
double sigmoid (double x)
 
double realDiv (double a, double b)
 
std::ostream & manipMetadataSkipLocation (std::ostream &)
 
std::ostream & manipMetadataWithLocation (std::ostream &)
 
std::ostream & manipMetadataOneLine (std::ostream &)
 
std::ostream & manipMetadataMultiLine (std::ostream &)
 
std::ostream & manipMetadataNoId (std::ostream &os)
 
std::ostream & manipMetadataPrintId (std::ostream &os)
 
std::ostream & operator<< (std::ostream &os, const Metadata &md)
 
TransformedMetadata makeMetadata (const std::string &op, const std::vector< Metadata > &sources)
 
SourceMetadata makeMetadata (const std::vector< std::string > &labels, const std::optional< std::pair< std::string, int > > &location, const Metadata &callerMetadata)
 
AnonymousMetadata makeMetadata (const ID &id={})
 
std::string toString (const Metadata &md, bool shouldSkipLocation=false)
 
template<std::integral T>
void exceptSafeParallelFor (T begin, T end, T step, const std::function< void(T)> &body, omp_sched_t schedKind, int schedChunkSize=0)
 
bool operator== (const SerialScope &lhs, const SerialScope &rhs)
 
bool operator== (const OpenMPScope &lhs, const OpenMPScope &rhs)
 
std::ostream & operator<< (std::ostream &os, const OpenMPScope &parallel)
 
bool operator== (const CUDAStreamScope &lhs, const CUDAStreamScope &rhs)
 
std::ostream & operator<< (std::ostream &os, const CUDAStreamScope &parallel)
 
bool operator== (const CUDAScope &lhs, const CUDAScope &rhs)
 
std::ostream & operator<< (std::ostream &os, const CUDAScope &parallel)
 
std::ostream & operator<< (std::ostream &os, const ParallelScope &parallel)
 
ParallelScope parseParallelScope (const std::string &_str)
 
Stmt annotateConds (const Stmt &op)
 
Stmt constFold (const Stmt &op)
 
Expr constFold (const Expr &op)
 
Stmt flattenStmtSeq (const Stmt &op)
 
Stmt floatSimplify (const Stmt &op)
 
Func hoistReturnVars (const Func &func)
 
Stmt hoistVarOverStmtSeq (const Stmt &op, const std::optional< std::vector< ID > > &togetherIds=std::nullopt)
 
Stmt makeHeapAlloc (const Stmt &op)
 
 DEFINE_PASS_FOR_FUNC (makeHeapAlloc)
 
template<class Titers , class Tbegins , class Tends , class Tsteps , class Tlens , class Tproperties , class Tbody >
Stmt makeNestedLoops (Titers &&iters, Tbegins &&begins, Tends &&ends, Tsteps &&steps, Tlens &&lens, Tproperties &&properties, Tbody &&body)
 
Stmt makeParallelReduction (const Stmt &op, const Ref< Target > &target)
 
Stmt makeReduction (const Stmt &op, const std::unordered_set< ReduceOp > &types, bool canonicalOnly=false)
 
Stmt makeReduction (const Stmt &op)
 
Stmt mergeAndHoistIf (const Stmt &op)
 
Stmt moveOutFirstOrLastIter (const Stmt &op)
 
Stmt normalizeLoops (const Stmt &op, const std::function< bool(const For &)> &filter=nullptr)
 
Stmt propOneTimeUse (const Stmt &op, const ID &subAST=ID())
 
Stmt refineSignDataType (const Stmt &op)
 
 DEFINE_PASS_FOR_FUNC (refineSignDataType)
 
Stmt removeCyclicAssign (const Stmt &op)
 
Stmt removeDeadVar (const Stmt &op)
 
Stmt removeWrites (const Stmt &op, const ID &singleDefId={})
 
Stmt scalarPropConst (const Stmt &op)
 
int findInnerMostScope (const std::unordered_map< std::string, int > &varScope, const Expr &op)
 
Stmt sinkVar (const Stmt &op, const std::optional< std::unordered_set< ID > > &toSink=std::nullopt, const std::function< bool(const Stmt &)> &scopeFilter=nullptr)
 
Stmt tensorPropConst (const Stmt &op, const ID &bothInSubAST=ID(), const ID &eitherInSubAST=ID())
 
Stmt undoMakeReduction (const ReduceTo &op, DataType dtype)
 
Stmt undoMakeReduction (const Stmt &op)
 
Stmt useBuiltinDiv (const Stmt &op)
 
Stmt z3Simplify (const Stmt &op)
 
Expr neutralVal (DataType dtype, ReduceOp op)
 
std::ostream & operator<< (std::ostream &os, AsMatMulMode mode)
 
Stmt asMatMul (const Stmt &ast, const ID &loop, MatMulBackend backend)
 
Stmt blend (const Stmt &ast, const ID &loop)
 
std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > cache (const Stmt &ast, const ID &stmt, const std::string &var, MemType mtype)
 
std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > cacheReduction (const Stmt &ast, const ID &stmt, const std::string &var, MemType mtype)
 
void checkNotInLib (const Stmt &ast, const ID &stmt)
 
void checkVarCrossParallel (const Stmt &ast, const ID &def, MemType mtype)
 
std::ostream & operator<< (std::ostream &os, FissionSide side)
 
std::pair< Stmt, std::pair< std::unordered_map< ID, ID >, std::unordered_map< ID, ID > > > fission (const Stmt &ast, const ID &loop, FissionSide side, const ID &splitter, bool allowEnlarge, const std::string &suffix0, const std::string &suffix1)
 
std::pair< Stmt, IDfuse (const Stmt &ast, const ID &loop0, const ID &loop1, bool strict)
 
Stmt inlining (const Stmt &ast, const ID &def)
 
Stmt lowerCutlassMicroBlock (const Stmt &ast, const ID &matMulId, const ID &defIdC, const std::vector< bool > &dimsCBatch, const std::vector< bool > &dimsCM, const std::vector< bool > &dimsCN)
 
std::pair< Stmt, IDmerge (const Stmt &ast, const ID &loop1, const ID &loop2)
 
Stmt parallelize (const Stmt &ast, const ID &loop, const ParallelScope &parallel, bool allowReduction)
 
Stmt parallelizeAs (const Stmt &ast, const ID &nest, const ID &reference, const ID &defId)
 
std::pair< Stmt, std::vector< ID > > permute (const Stmt &ast, const std::vector< ID > &loopsId, const std::function< std::vector< Expr >(std::vector< Expr >)> &transformFunc)
 
std::pair< Stmt, std::pair< ID, int > > plutoFuse (const Stmt &ast, const ID &loop0, const ID &loop1, int nestLevel0, int nestLevel1, int fusableOverlapThreshold, int fusableNonOverlapTolerance, bool doSimplify=true)
 
std::pair< Stmt, std::pair< ID, int > > plutoPermute (const Stmt &ast, const ID &loop, int nestLevel, bool doSimplify=true)
 
std::ostream & operator<< (std::ostream &os, ReorderMode mode)
 
Stmt reorder (const Stmt &ast, const std::vector< ID > &order, ReorderMode mode)
 
std::ostream & operator<< (std::ostream &os, ScheduleType type)
 
std::ostream & operator<< (std::ostream &os, const IDMetadataPack &pack)
 
template<typename... Args>
auto getIDFromPack (const std::tuple< Args... > &args)
 
template<typename... Args>
auto getMetadataFromPack (const std::tuple< Args... > &args)
 
template<typename... Args>
auto getPackFromID (auto schedule, const std::tuple< Args... > &args)
 
std::ostream & operator<< (std::ostream &os, const ScheduleLogItem &log)
 
Stmt separateTail (const Stmt &ast, bool noDuplicateVarDefs)
 
Stmt setMemType (const Stmt &ast, const ID &def, MemType mtype, bool rejectIndirectAccess)
 
std::pair< Stmt, std::pair< ID, ID > > split (const Stmt &ast, const ID &id, int factor, int nparts, int shift=0)
 
Stmt swap (const Stmt &ast, const std::vector< ID > &order)
 
Stmt unroll (const Stmt &ast, const ID &loop, bool immediate)
 
Stmt varMerge (const Stmt &ast, const ID &def, int dim)
 
Stmt varReorderImpl (const Stmt &ast, const ID &def, const std::vector< int > &order, bool forceReorderInMatMul=false)
 
Stmt varReorder (const Stmt &ast, const ID &def, const std::vector< int > &order)
 
Stmt varSplit (const Stmt &ast, const ID &def, int dim, VarSplitMode mode, int factor, int nparts)
 
Stmt varSqueeze (const Stmt &ast, const ID &def, int dim)
 
Stmt varUnsqueeze (const Stmt &ast, const ID &def, int dim)
 
Stmt vectorize (const Stmt &ast, const ID &loop)
 
Ref< SelectorparseSelector (const std::string &str)
 
AST loadAST (const std::string &txt)
 
Ref< TargetloadTarget (const std::string &txt, const std::string &data)
 
Ref< DeviceloadDevice (const std::string &txt, const std::string &data)
 
Ref< ArrayloadArray (const std::string &txt, const std::string &data)
 
Ref< ArraynewArray (const std::vector< size_t > &shape_, const std::string &dtype_, const std::string &data_)
 
std::string mangle (const std::string &name)
 
std::string unmangle (const std::string &name)
 
std::string dumpAST (const AST &op, bool dtypeInLoad=false, bool hexFloat=true)
 
std::pair< std::string, std::string > dumpTarget (const Ref< Target > &target_)
 
std::pair< std::string, std::string > dumpDevice (const Ref< Device > &device_)
 
std::pair< std::string, std::string > dumpArray (const Ref< Array > &array_)
 
template<typename Func >
auto operator<< (std::ostream &os, const Func &func) -> decltype(func(os))
 
template<class T >
requires requires(const T &obj) { requires HasStreamOutput<T>; requires !std::convertible_to<T, Ref<ASTNode>>; }
std::string toString (const T &obj)
 
Stmt makeAny (std::source_location loc=std::source_location::current())
 
template<class Tstmts >
Stmt makeStmtSeq (Tstmts &&stmts, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
Stmt makeStmtSeq (std::initializer_list< Stmt > stmts, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tbuffer , class Tbody >
Stmt makeVarDef (const std::string &name, Tbuffer &&buffer, const std::optional< std::string > &viewOf, Tbody &&body, bool pinned, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tindices , class Texpr >
Stmt makeStore (const std::string &var, Tindices &&indices, Texpr &&expr, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Texpr >
Stmt makeStore (const std::string &var, const std::vector< Expr > &indices, Texpr &&expr, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
Stmt makeAlloc (const std::string &var, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
Stmt makeFree (const std::string &var, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tindices , class Texpr >
Stmt makeReduceTo (const std::string &var, Tindices &&indices, ReduceOp op, Texpr &&expr, bool sync, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Texpr >
Stmt makeReduceTo (const std::string &var, const std::vector< Expr > &indices, ReduceOp op, Texpr &&expr, bool sync, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tbegin , class Tend , class Tstep , class Tlen , class Tbody , class Tproperty >
Stmt makeFor (const std::string &iter, Tbegin &&begin, Tend &&end, Tstep &&step, Tlen &&len, Tproperty &&property, Tbody &&body, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tcond , class Tthen , class Telse = std::nullptr_t>
Stmt makeIf (Tcond &&cond, Tthen &&thenCase, Telse &&elseCase, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tcond , class Tthen , class Telse = std::nullptr_t>
Stmt makeIf (Tcond &&cond, Tthen &&thenCase, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tcond , class Tbody >
Stmt makeAssert (Tcond &&cond, Tbody &&body, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class Tcond , class Tbody >
Stmt makeAssume (Tcond &&cond, Tbody &&body, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
template<class T >
Stmt makeEval (T &&expr, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
std::ostream & operator<< (std::ostream &os, MatMulBackend backend)
 
MatMulBackend parseMatMulBackend (const std::string &_str)
 
Stmt makeMatMul (MatMulBackend backend, const Ref< CutlassMicroKernelProperty > &cutlassMicroKernelProperty, const Expr &a, const Expr &b, const Expr &c, const Expr &alpha, const Expr &beta, const Expr &m, const Expr &k, const Expr &n, const Expr &lda, const Expr &ldb, const Expr &ldc, const Expr &stridea, const Expr &strideb, const Expr &stridec, const Expr &batchSize, bool aIsRowMajor, bool bIsRowMajor, bool cIsRowMajor, const Stmt &equivalent, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
Stmt makeMarkVersion (const std::string &tapeName, const std::string &var, const Metadata &metadata=nullptr, const ID &id={}, std::source_location loc=std::source_location::current())
 
Ref< ASTPartlca (const Ref< ASTPart > &lhs, const Ref< ASTPart > &rhs)
 
template<class T >
detail::TaggedSyncFunc< std::remove_reference_t< T > > syncFunc (T &&f)
 
template<class T >
detail::TaggedUnsyncFunc< std::remove_reference_t< T > > unsyncFunc (T &&f)
 
template<class T >
Ref< TensormakeTensor (T &&shape, DataType dtype)
 
Ref< TensormakeTensor (std::initializer_list< Expr > shape, DataType dtype)
 
Ref< TensordeepCopy (const Ref< Tensor > &t)
 
bool timeout (const std::function< void()> &func, int seconds)
 
std::ostream & operator<< (std::ostream &os, AccessType atype)
 
AccessType parseAType (const std::string &_str)
 
bool isWritable (AccessType atype)
 
bool isInputting (AccessType atype)
 
bool isOutputting (AccessType atype)
 
AccessType addOutputting (AccessType atype)
 
AccessType removeOutputting (AccessType atype)
 
std::ostream & operator<< (std::ostream &os, BaseDataType dtype)
 
BaseDataType parseBaseDataType (const std::string &_str)
 
std::ostream & operator<< (std::ostream &os, SignDataType dtype)
 
SignDataType parseSignDataType (const std::string &str)
 
std::ostream & operator<< (std::ostream &os, const DataType &dtype)
 
DataType parseDType (const std::string &str)
 
size_t sizeOf (BaseDataType dtype)
 
size_t sizeOf (const DataType &dtype)
 
bool isInt (BaseDataType dtype)
 
bool isInt (const DataType &dtype)
 
bool isFloat (BaseDataType dtype)
 
bool isFloat (const DataType &dtype)
 
bool isNumber (BaseDataType dtype)
 
bool isNumber (const DataType &dtype)
 
bool isBool (BaseDataType dtype)
 
bool isBool (const DataType &dtype)
 
bool isGT0 (SignDataType dtype)
 
bool isGT0 (const DataType &dtype)
 
bool isGE0 (SignDataType dtype)
 
bool isGE0 (const DataType &dtype)
 
bool isLT0 (SignDataType dtype)
 
bool isLT0 (const DataType &dtype)
 
bool isLE0 (SignDataType dtype)
 
bool isLE0 (const DataType &dtype)
 
bool isNE0 (SignDataType dtype)
 
bool isNE0 (const DataType &dtype)
 
bool isEQ0 (SignDataType dtype)
 
bool isEQ0 (const DataType &dtype)
 
BaseDataType downCast (BaseDataType lhs, BaseDataType rhs)
 
SignDataType downCast (SignDataType lhs, SignDataType rhs)
 
DataType downCast (const DataType &lhs, const DataType &rhs)
 
std::ostream & operator<< (std::ostream &os, MemType mtype)
 
MemType parseMType (const std::string &_str)
 
template<class FromMap , class ToMap >
void copyInfo (const FromMap &fromInfo, const typename FromMap::key_type &from, ToMap &toInfo, const typename ToMap::key_type &to)
 
template<class FromMap , class ToMap >
void meetTo (const FromMap &fromInfo, const typename FromMap::key_type &from, ToMap &toInfo, const typename ToMap::key_type &to)
 
std::ostream & operator<< (std::ostream &os, const StmtOrExprID &id)
 
bool operator== (const StmtOrExprID &lhs, const StmtOrExprID &rhs)
 
bool operator== (const ID &lhs, const ID &rhs)
 
std::ostream & operator<< (std::ostream &os, const PBBuildExpr &e)
 
std::ostream & operator<< (std::ostream &os, const Ref< MetadataContent > &mdc)
 
 BINARY_OP_F (Min, [](auto &&lhs, auto &&rhs) { typedef decltype(lhs+rhs) V;return std::min< V >(lhs, rhs);}) BINARY_OP_F(Max
 
std::ostream & operator<< (std::ostream &os, const DiscreteRandVar &var)
 
std::ostream & operator<< (std::ostream &os, const DiscreteObservation &obs)
 
template<typename T >
std::optional< T > optMul (const std::optional< T > &lhs, const std::optional< T > &rhs)
 
std::vector< FindDepsDirnotLexLessAfterPermu (const std::vector< For > &outers, const std::vector< ID > &permu)
 
std::unordered_set< std::string > allUses (const AST &op, AllUses::AllUsesType type=AllUses::CHECK_LOAD|AllUses::CHECK_STORE|AllUses::CHECK_REDUCE, bool noRecurseIdx=false, bool noRecurseSubStmt=false)
 
std::unordered_set< std::string > allUses (const auto &filter, const Stmt &op, AllUses::AllUsesType type=AllUses::CHECK_LOAD|AllUses::CHECK_STORE|AllUses::CHECK_REDUCE, bool noRecurseIdx=false)
 
std::unordered_set< std::string > allReads (const AST &op, bool noRecurseIdx=false, bool noRecurseSubStmt=false)
 
std::unordered_set< std::string > allReads (const auto &filter, const Stmt &op, bool noRecurseIdx=false)
 
std::unordered_set< std::string > allWrites (const AST &op, bool noRecurseIdx=false, bool noRecurseSubStmt=false)
 
std::unordered_set< std::string > allWrites (const auto &filter, const Stmt &op, bool noRecurseIdx=false)
 
std::unordered_set< std::string > allIters (const AST &op, bool noRecurseIdx=false, bool noRecurseSubStmt=false)
 
std::unordered_set< std::string > allIters (const auto &filter, const Stmt &op, bool noRecurseIdx=false)
 
std::unordered_set< std::string > allNames (const AST &op, bool noRecurseIdx=false, bool noRecurseSubStmt=false)
 
std::unordered_set< std::string > allNames (const auto &filter, const Stmt &op, bool noRecurseIdx=false)
 
std::optional< bool > checkNotModifiedFastPreCheck (const Stmt &op, const Expr &expr, CheckNotModifiedSide s0Side, const ID &s0, CheckNotModifiedSide s1Side, const ID &s1)
 
std::optional< bool > checkNotModifiedFastPreCheck (const Stmt &op, const Expr &s0Expr, const Expr &s1Expr, CheckNotModifiedSide s0Side, const ID &s0, CheckNotModifiedSide s1Side, const ID &s1)
 
std::vector< StmtfindAllStmt (const Stmt &ast, const ID &id)
 
std::vector< StmtfindAllStmt (const Stmt &ast, const std::function< bool(const Stmt &)> &filter)
 
std::vector< StmtfindAllStmt (const Stmt &ast, const Ref< Selector > &selector)
 
std::vector< StmtfindAllStmt (const Stmt &ast, const std::string &pattern)
 
template<class T >
std::vector< StmtfindAllStmt (const Func &func, const T &filter)
 
Stmt findStmt (const Stmt &ast, const ID &id)
 
Stmt findStmt (const Stmt &ast, const std::function< bool(const Stmt &)> &filter)
 
Stmt findStmt (const Stmt &ast, const Ref< Selector > &selector)
 
Stmt findStmt (const Stmt &ast, const std::string &pattern)
 
template<class T >
Stmt findStmt (const Func &func, const T &filter)
 
std::tuple< Stmt, Stmt, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string >, std::unordered_map< ID, std::string > > gradBody (const Stmt &op, const std::unordered_set< std::string > &_requires, const std::unordered_set< std::string > &provides, const TapeStrategy &tapes, bool resetProvidedGrad=true, bool invert=false, const std::vector< StmtSetToUserGrad > &userGrads={})
 
std::tuple< Func, Func, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string > > gradFuncInplace (const Func &func, const std::unordered_set< std::string > &_requires, const std::unordered_set< std::string > &provides, const TapeStrategy &tapes, bool tapeInClosure=true, bool resetProvidedGrad=true, bool invert=false, const std::vector< StmtSetToUserGrad > &userGrads={})
 
std::tuple< Func, Func, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string > > gradFuncOutOfPlace (const Func &func, const std::unordered_set< std::string > &_requires, const std::unordered_set< std::string > &provides, const TapeStrategy &tapes, bool tapeInClosure=true, bool resetProvidedGrad=true, bool invert=false, const std::vector< StmtSetToUserGrad > &userGrads={})
 
std::string toString (const AST &op)
 
std::string toString (const AST &op, bool pretty)
 
std::string toString (const AST &op, bool pretty, bool printAllId)
 
std::string toString (const AST &op, bool pretty, bool printAllId, bool dtypeInLoad, bool hexFloat=false, bool compact=false, bool parenDespitePriority=false)
 
std::string toString (const AST &op, bool pretty, bool printAllId, bool dtypeInLoad, bool hexFloat, bool compact, bool parenDespitePriority, bool printSourceLocation)
 
PBFuncAST parsePBFunc (const PBFunc::Serialized &f)
 
PBFuncAST parsePBFunc (const PBSingleFunc::Serialized &f)
 
PBFuncAST parsePBFuncReconstructMinMax (const PBSet &set)
 
PBFuncAST parsePBFuncReconstructMinMax (const PBMap &map)
 
SimplePBFuncAST parseSimplePBFunc (const auto &f)
 
SimplePBFuncAST parseSimplePBFuncReconstructMinMax (const auto &f)
 
template<PBMapRef T>
PBMap moveDimsInputToParam (T &&map, unsigned first, unsigned n, unsigned target)
 
template<PBMapRef T>
PBMap moveDimsOutputToParam (T &&map, unsigned first, unsigned n, unsigned target)
 
Stmt renameVar (const Stmt &op, const std::unordered_map< std::string, std::string > &rename)
 
Stmt renameVar (const Stmt &op, const std::string &oldName, const std::string &newName)
 
Stmt shrinkFor (const Stmt &op, const ID &subAST=ID(), bool doSimplify=true, bool unordered=false)
 
Stmt shrinkFor (const Stmt &op, const Stmt &subAST, bool doSimplify=true, bool unordered=false)
 
Stmt shrinkLinearIndices (const Stmt &ast, const ID &vardef)
 
Stmt shrinkLinearIndices (const Stmt &ast)
 
Stmt shrinkVar (const Stmt &op)
 
Stmt shrinkSingleVar (const Stmt &op, const ID &varDefId)
 
Stmt builtinSimplify (const Stmt &op)
 
Stmt pbSimplify (const Stmt &op)
 
Stmt simplify (const Stmt &op)
 
Stmt hoistSelectedVar (const Stmt &op, const std::string &selector)
 
Stmt hoistSelectedVar (const Stmt &op, const Ref< Selector > &selector)
 
BaseDataType upCast (BaseDataType lhs, BaseDataType rhs)
 
SignDataType upCast (SignDataType lhs, SignDataType rhs)
 
DataType upCast (const DataType &lhs, const DataType &rhs)
 

Variables

constexpr int SMALL_ITEM_SIZE = 64
 
constexpr int SMALL_ITEM_PER_BLOCK = 16384 / SMALL_ITEM_SIZE
 
const CompAccessBoundMode COMP_ACCESS_BOUND_READ = 0x1
 
const CompAccessBoundMode COMP_ACCESS_BOUND_WRITE = 0x2
 
const CompAccessBoundMode COMP_ACCESS_BOUND_ALL
 
const DepType DEP_WAW = 0x1
 
const DepType DEP_WAR = 0x2
 
const DepType DEP_RAW = 0x4
 
const DepType DEP_ALL = DEP_WAW | DEP_WAR | DEP_RAW
 
constexpr ParallelScope serialScope = SerialScope{}
 
constexpr ParallelScope threadIdxX = CUDAScope{CUDAScope::Thread, CUDAScope::X}
 
constexpr ParallelScope threadIdxY = CUDAScope{CUDAScope::Thread, CUDAScope::Y}
 
constexpr ParallelScope threadIdxZ = CUDAScope{CUDAScope::Thread, CUDAScope::Z}
 
constexpr ParallelScope blockIdxX = CUDAScope{CUDAScope::Block, CUDAScope::X}
 
constexpr ParallelScope blockIdxY = CUDAScope{CUDAScope::Block, CUDAScope::Y}
 
constexpr ParallelScope blockIdxZ = CUDAScope{CUDAScope::Block, CUDAScope::Z}
 
constexpr std::array scheduleTypeNames
 
constexpr std::array matMulBackendNames
 
constexpr std::array accessTypeNames
 
constexpr auto allAccessTypes
 
constexpr std::array baseDataTypeNames
 
constexpr auto allBaseDataTypes
 
constexpr std::array signDataTypeNames
 
constexpr auto allSignDataTypes
 
constexpr std::array memTypeNames
 
constexpr auto allMemTypes
 
auto && lhs
 
auto auto && rhs
 
int OSTREAM_NO_ID_SIGN = std::ostream::xalloc()
 
std::function< std::ostream &(std::ostream &)> manipNoIdSign (bool flag)
 
int OSTREAM_NO_PRETTY = std::ostream::xalloc()
 
std::function< std::ostream &(std::ostream &)> manipNoPrettyAST (bool flag)
 

Typedef Documentation

◆ Abs

◆ Add

◆ Alloc

◆ AnonymousMetadata

◆ Any

◆ AnyExpr

◆ Assert

◆ Assume

◆ AST

◆ ASTHashMap

template<class K , class V >
using freetensor::ASTHashMap = typedef std::unordered_map<K, V, Hasher, HashComparator>

◆ ASTHashSet

template<class K >
using freetensor::ASTHashSet = typedef std::unordered_set<K, Hasher, HashComparator>

◆ BinaryExpr

◆ BoolConst

◆ Cast

◆ Ceil

◆ CeilDiv

◆ CommutativeBinaryExpr

◆ CompAccessBoundMode

◆ Const

◆ Cos

◆ DepType

typedef int freetensor::DepType

◆ DNF

typedef std::vector<std::vector<Expr> > freetensor::DNF

◆ EQ

◆ Eval

◆ Exp

◆ Expr

◆ FindDepsAccFilter

◆ FindDepsAccPtFilter

typedef std::function<bool(const AccessPoint &)> freetensor::FindDepsAccPtFilter

◆ FindDepsCallback

◆ FindDepsDir

typedef std::vector<std::pair<NodeIDOrParallelScope, DepDirection> > freetensor::FindDepsDir

◆ FindDepsFilter

typedef std::function<bool(const AccessPoint &later, const AccessPoint &earlier)> freetensor::FindDepsFilter

◆ FloatConst

◆ Floor

◆ FloorDiv

◆ For

◆ Free

◆ Func

◆ GE

◆ GT

◆ IDMetadataPack

using freetensor::IDMetadataPack = typedef std::pair<ID, Metadata>

◆ If

◆ IfExpr

◆ IntConst

◆ Intrinsic

◆ LAnd

◆ LE

◆ Ln

◆ LNot

◆ Load

◆ LoadAtVersion

◆ LoopVariExprMap

typedef std::unordered_map<StmtOrExprID , std::unordered_map<ID, LoopVariability> > freetensor::LoopVariExprMap

◆ LoopVariTransVarMap

typedef std::unordered_map<std::string, std::unordered_map<ID, LoopVariability> > freetensor::LoopVariTransVarMap

◆ LoopVariUniqVarMap

typedef std::unordered_map<ID , std::unordered_map<ID, LoopVariability> > freetensor::LoopVariUniqVarMap

◆ LOr

◆ LT

◆ MarkVersion

◆ MatMul

◆ Max

◆ Metadata

◆ MetadataComparator

◆ MetadataHasher

◆ Min

◆ Mod

◆ Mul

◆ NE

◆ NonCommutativeBinaryExpr

◆ ParallelScope

◆ PBFuncAST

typedef std::vector<SimplePBFuncAST> freetensor::PBFuncAST

A PBFunc parsed as ASTs

◆ ProgramPosition

◆ RandCondStack

◆ RandTrace

◆ RealDiv

◆ ReduceTo

◆ Remainder

◆ RoundTowards0Div

◆ ScheduleLog

◆ Sigmoid

◆ Sin

◆ SourceMetadata

◆ Sqrt

◆ Square

◆ Stmt

◆ StmtSeq

◆ Store

◆ Sub

◆ Tan

◆ Tanh

◆ TransformedMetadata

◆ UnaryExpr

◆ Unbound

◆ Var

◆ VarDef

Enumeration Type Documentation

◆ AccessType

enum class freetensor::AccessType : size_t
strong

AccessType describes whether a tensor can be read or written

An AccessType is decided by the following properties:

  • Writable: Writable in the program. The written result may or may not be seen on user buffers.
  • Inputting: The program needs user input to tensors of this type.
  • Outputting: Users need output from tensors of this type. But even when a tensor is not outputting, it may still be modified.

Types for each combinations of the properties are:

Name | Writable | Inputting | Outputting
NO USE | NO | NO | NO
NO USE | NO | NO | YES
input | NO | YES | NO
bypass | NO | YES | YES
cache | YES | NO | NO
output | YES | NO | YES
input-mutable(*) | YES | YES | NO
inout | YES | YES | YES
std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > cache(const Stmt &ast, const ID &stmt, const std::string &var, MemType mtype)
Definition: cache.cc:264

(*) The written data may or may not be visible to user, depending on whether the Array is moved.

Enumerator
Input 
Bypass 
Cache 
Output 
InputMutable 
InOut 
NumTypes 

◆ AsMatMulMode

enum class freetensor::AsMatMulMode : int
strong
Enumerator
KeepMemLayout 
TryVarReorder 
TryTranspose 

◆ ASTNodeType

enum class freetensor::ASTNodeType : int
strong
Enumerator
Any 
AnyExpr 
Func 
Store 
ReduceTo 
Load 
Alloc 
Free 
StmtSeq 
VarDef 
For 
If 
Assert 
Assume 
MatMul 
Eval 
Var 
IntConst 
FloatConst 
BoolConst 
Add 
Sub 
Mul 
RealDiv 
FloorDiv 
CeilDiv 
RoundTowards0Div 
Mod 
Remainder 
Min 
Max 
LT 
LE 
GT 
GE 
EQ 
NE 
LAnd 
LOr 
LNot 
Sqrt 
Exp 
Ln 
Square 
Sigmoid 
Sin 
Cos 
Tan 
Tanh 
Abs 
Floor 
Ceil 
Unbound 
IfExpr 
Cast 
Intrinsic 
MarkVersion 
LoadAtVersion 

◆ BaseDataType

enum class freetensor::BaseDataType : size_t
strong
Enumerator
Void 
Float16 
Float32 
Float64 
Int32 
Int64 
Bool 
Custom 
Never 
NumTypes 

◆ CheckNotModifiedSide

enum class freetensor::CheckNotModifiedSide : int
strong
Enumerator
Before 
After 

◆ DepDirection

enum class freetensor::DepDirection : int
strong
Enumerator
Normal 
Inv 
Same 
Different 

◆ FindDepsMode

enum class freetensor::FindDepsMode : int
strong
Enumerator
Dep 
KillEarlier 
KillLater 
KillBoth 

◆ FindLoopInScopesDirection

enum class freetensor::FindLoopInScopesDirection : int
strong
Enumerator
Front 
Back 

◆ FissionSide

enum class freetensor::FissionSide : int
strong
Enumerator
Before 
After 

◆ FrontendVarIdxType

enum class freetensor::FrontendVarIdxType : int
strong
Enumerator
Single 
Slice 

◆ GradTapeMode

enum class freetensor::GradTapeMode : int
strong

Mode of which intermediate variables should be stored.

Enumerator
All 
Nothing 

Store all variables including local scalars.

NoReuseOnly 

Store nothing.

Store variables that only hold one version of data, which means we do not have to store each version of them in their history.

◆ LoopVariability

enum class freetensor::LoopVariability : int
strong
Enumerator
Unknown 
Variant 

◆ MatMulBackend

enum class freetensor::MatMulBackend : size_t
strong

Backend library of MatMul nodes

Enumerator
Mkl 
Cublas 
Cutlass 
CutlassMicroBlock 
CutlassMicroThread 
NumBackends 

◆ MemType

enum class freetensor::MemType : size_t
strong
Enumerator
ByValue 
CPU 
GPUGlobal 
GPUShared 
GPULocal 
GPUWarp 
CPUHeap 
GPUGlobalHeap 
NumTypes 

◆ MetadataType

enum class freetensor::MetadataType
strong
Enumerator
Transformed 
Source 
Anonymous 

◆ MoveToSide

enum class freetensor::MoveToSide : int
strong
Enumerator
Before 
After 

◆ NullPolicy

Enumerator
NotNull 
Nullable 

◆ OutputIntermediatesStage

enum class freetensor::OutputIntermediatesStage : int
strong
Enumerator
Forward 
Backward 

◆ ReduceOp

enum class freetensor::ReduceOp : int
strong

Operation of a ReduceTo node

All operations should obey the following laws, where ?= is any of the reduction operations:

  1. (Communicative) a ?= b; a ?= c equals to a ?= c; a ?= b.
  2. (Associative) x ?= a; x ?= b; x ?= c; x ?= d equals to `y = neutral_value; y ?= a; y ?= b; z = neutral_value; z ?= c; z ?= d; x ?= y; x ?= z`.

Counter-examples:

  • -= or /= for RealDiv is not a reduction because it is against Law 2. Thus, -= x or /= x will be lowered to += -x or *= 1 / x to obey the law. (NOTE: /= for RoundTowards0Div is also against Law 2, but it cannot be lowered *= 1 / x, thus we cannot do parallel reduction for RoundTowards0Div).
  • /= for FloorDiv is not only agains Law 2, but also against Law 1. E.g., 603 // 625 // -492 == 0, but 603 // -492 // 625 == -1.
Enumerator
Add 
Mul 
Min 
Max 
LAnd 
LOr 

◆ ReorderMode

enum class freetensor::ReorderMode : int
strong
Enumerator
PerfectOnly 
MoveOutImperfect 
MoveInImperfect 

◆ ScheduleType

enum class freetensor::ScheduleType : int
strong
Enumerator
Split 
Reorder 
Merge 
Fission 
Fuse 
Swap 
Blend 
Cache 
CacheReduction 
SetMemType 
VarSplit 
VarMerge 
VarReorder 
VarUnsqueeze 
VarSqueeze 
Inline 
Parallelize 
ParallelizeAs 
Unroll 
Vectorize 
SeparateTail 
AsMatMul 
Permute 
PlutoFuse 
PlutoPermute 
NumTypes 

◆ SignDataType

enum class freetensor::SignDataType : size_t
strong
Enumerator
Any 
GT0 
GE0 
LT0 
LE0 
NE0 
EQ0 
Never 
NumTypes 

◆ TargetType

enum class freetensor::TargetType : int
strong
Enumerator
CPU 
GPU 

◆ VarSplitMode

Enumerator
FixedSize 
RelaxedSize 

Function Documentation

◆ _COPY_ISL_PTR()

template<class T >
T * freetensor::_COPY_ISL_PTR ( const T *  ptr,
T *  copy)(T * 
)

◆ add() [1/3]

template<class T >
LinearExpr< T > freetensor::add ( const LinearExpr< T > &  lhs,
const LinearExpr< T > &  rhs 
)

◆ add() [2/3]

LowerBound freetensor::add ( const LowerBound b1,
const LowerBound b2 
)

◆ add() [3/3]

UpperBound freetensor::add ( const UpperBound b1,
const UpperBound b2 
)

◆ addOutputting()

AccessType freetensor::addOutputting ( AccessType  atype)
inline

◆ allDefs()

std::vector< std::pair< ID, std::string > > freetensor::allDefs ( const Stmt op,
const std::unordered_set< AccessType > &  atypes = allAccessTypes | ranges::to<std::unordered_set>() 
)
inline

Collect IDs of all VarDef nodes of specific AccessTypes

◆ allIters() [1/2]

std::unordered_set< std::string > freetensor::allIters ( const AST op,
bool  noRecurseIdx = false,
bool  noRecurseSubStmt = false 
)
inline

Find names of all iterators of For nodes that are used

◆ allIters() [2/2]

std::unordered_set< std::string > freetensor::allIters ( const auto &  filter,
const Stmt op,
bool  noRecurseIdx = false 
)
inline

◆ allNames() [1/2]

std::unordered_set< std::string > freetensor::allNames ( const AST op,
bool  noRecurseIdx = false,
bool  noRecurseSubStmt = false 
)
inline

Find names of all VarDef nodes that are read or written, and all iterators of For nodes that are used

◆ allNames() [2/2]

std::unordered_set< std::string > freetensor::allNames ( const auto &  filter,
const Stmt op,
bool  noRecurseIdx = false 
)
inline

◆ allNoReuseDefs()

std::vector< ID > freetensor::allNoReuseDefs ( const Stmt op,
const std::unordered_set< AccessType > &  atypes 
)

◆ allReads() [1/3]

std::unordered_set< std::string > freetensor::allReads ( const AST op,
bool  noRecurseIdx = false,
bool  noRecurseSubStmt = false 
)
inline

Find names of all VarDef nodes that are read

◆ allReads() [2/3]

std::unordered_set< std::string > freetensor::allReads ( const auto &  filter,
const Stmt op,
bool  noRecurseIdx = false 
)
inline

◆ allReads() [3/3]

std::unordered_set< std::string > freetensor::allReads ( const FrontendVarIdx idx)

◆ allSideEffectIntrinsics()

template<typename T >
std::unordered_set< Intrinsic > freetensor::allSideEffectIntrinsics ( T &&  op)

◆ allUses() [1/2]

std::unordered_set< std::string > freetensor::allUses ( const AST op,
AllUses::AllUsesType  type = AllUses::CHECK_LOAD | AllUses::CHECK_STORE | AllUses::CHECK_REDUCE,
bool  noRecurseIdx = false,
bool  noRecurseSubStmt = false 
)

Find names of VarDef nodes or iterators of For nodes used in a specific type of manner

Parameters
type: Filter how the name is used
filter: Filter statements to find. Can be a fn(Stmt) -> bool or a Ref<Selector> or a selector string. If using filter, you must filter all statements including those in the sub-trees (noRecurseSubStmt is always set to true).
noRecurseIdx: If true, do not include names used as indirect indices
noRecurseSubStmt: If true, consider only the root statement(s)

◆ allUses() [2/2]

std::unordered_set< std::string > freetensor::allUses ( const auto &  filter,
const Stmt op,
AllUses::AllUsesType  type = AllUses::CHECK_LOAD | AllUses::CHECK_STORE | AllUses::CHECK_REDUCE,
bool  noRecurseIdx = false 
)
inline

◆ allWrites() [1/2]

std::unordered_set< std::string > freetensor::allWrites ( const AST op,
bool  noRecurseIdx = false,
bool  noRecurseSubStmt = false 
)
inline

Find names of all VarDef nodes that are written

◆ allWrites() [2/2]

std::unordered_set< std::string > freetensor::allWrites ( const auto &  filter,
const Stmt op,
bool  noRecurseIdx = false 
)
inline

◆ alwaysLE()

bool freetensor::alwaysLE ( const UpperBound b1,
const LowerBound b2 
)

◆ alwaysLT()

bool freetensor::alwaysLT ( const UpperBound b1,
const LowerBound b2 
)

◆ analyzeVersion()

std::tuple< std::unordered_map< StmtOrExprID, Expr >, std::unordered_map< ID, Expr >, std::unordered_set< ID >, std::unordered_map< std::string, std::pair< std::string, Expr > > > freetensor::analyzeVersion ( const Stmt op,
const std::unordered_map< ID, std::unordered_set< ID > > &  needVersions,
const std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &  derivatives,
bool  localVersionsOnly 
)

Assign each memory access an expression that identifies each version of the accessed variable

Versions are guaranteed to distinguish READ sites that may reads different values. Versions of WRITE sites are assigned to be consistent to the READ sites. This also means the following:

  • Multiple READ sites may have the same version
  • There can be multiple WRITE sites even there is only one version

Some variables are TRIVIAL and there is no need to distinguish their versions. This function also outputs information of tribial variables. A variable is considered trivial if:

  • There is only one version, AND
  • The value of the only version is not overwritten by un-versioned writes till the end of the variable's lifetime
Parameters
op: The AST to analyze
needVersions: {VarDef ID -> ID of Statements to analyze}
derivatives: Lazy derivative generators for each statement. We need this information to determine which values are to be used in gradients
localVersionsOnly: If true, analyze local versions inside its VarDef node. If false, analyze global versions within the whole program
Returns
: (node -> versions, VarDef IDs -> total version counts, trivial VarDef IDs, tape_name -> var name, explicit user versions marked via mark_version)

◆ annotateConds()

Stmt freetensor::annotateConds ( const Stmt op)
inline

Some conditions are implicit in If or Assert, this pass annotates the AST by introducing extra Assume nodes

This pass clears all previously set Assume nodes

Currently, this pass annotates in the following situations

  1. Conditions on R/W variables

If the condition of an If or Assert node is related to an R/W variable, the condition may not hold in all statments in the body. For example:

if (x < 4) {
// stmt 1
x += 1
// stmt 2
}

The condition x < 4 may no longer hold for stmt 2. Therefore, we annotate the AST by transform it into

if (x < 4) {
assume (x < 4) {
// stmt 1
}
x += 1
// stmt 2
}

◆ apply()

template<PBSetRef T, PBMapRef U>
PBSet freetensor::apply ( T &&  lhs,
U &&  rhs 
)

◆ applyDomain()

template<PBMapRef T, PBMapRef U>
PBMap freetensor::applyDomain ( T &&  lhs,
U &&  rhs 
)

◆ applyRange()

template<PBMapRef T, PBMapRef U>
PBMap freetensor::applyRange ( T &&  lhs,
U &&  rhs 
)

◆ asDNF()

DNF freetensor::asDNF ( const Expr expr)

Normalize an bool expression to be a disjunctive normal form

◆ asExprGenerator() [1/3]

std::function< Expr()> freetensor::asExprGenerator ( const Expr e)
inline

◆ asExprGenerator() [2/3]

std::function< Expr()> freetensor::asExprGenerator ( const std::function< Expr()> &  e)
inline

◆ asExprGenerator() [3/3]

std::function< Expr()> freetensor::asExprGenerator ( std::nullptr_t  )
inline

◆ asMatMul()

Stmt freetensor::asMatMul ( const Stmt ast,
const ID loop,
MatMulBackend  backend 
)

◆ BINARY_OP_F()

freetensor::BINARY_OP_F ( Min  ,
[] (auto &&lhs, auto &&rhs) { typedef decltype(lhs+rhs) V;return std::min< V >(lhs, rhs);}   
)

◆ blend()

Stmt freetensor::blend ( const Stmt ast,
const ID loop 
)

◆ builtinSimplify()

Stmt freetensor::builtinSimplify ( const Stmt op)

Simplify integer expressions in a program

builtinSimplify and simplify uses CompUniqueBoundsCombination to simplify the program. pbSimplify uses CompUniqueBoundsPB to simplify the program.

This pass can only be applied on a complete program, instead of a single expression, because it examines VarDef nodes of each Var

Returns
: The simplified AST

◆ cache()

std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > freetensor::cache ( const Stmt ast,
const ID stmt,
const std::string &  var,
MemType  mtype 
)

◆ cacheReduction()

std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > freetensor::cacheReduction ( const Stmt ast,
const ID stmt,
const std::string &  var,
MemType  mtype 
)

◆ cartesianProduct()

template<PBSetRef T, PBSetRef U>
PBSet freetensor::cartesianProduct ( T &&  lhs,
U &&  rhs 
)

◆ cat()

template<class T >
std::vector< T > freetensor::cat ( const std::vector< T > &  lhs,
const std::vector< T > &  rhs 
)

◆ ceilDiv() [1/3]

LowerBound freetensor::ceilDiv ( const LowerBound b,
int  k 
)

◆ ceilDiv() [2/3]

UpperBound freetensor::ceilDiv ( const UpperBound b,
int  k 
)

◆ ceilDiv() [3/3]

auto freetensor::ceilDiv ( IntegralExceptBool auto  a,
IntegralExceptBool auto  b 
)
inline

◆ checkAllDefined() [1/2]

bool freetensor::checkAllDefined ( const std::unordered_set< std::string > &  defs,
const AST op 
)
inline

◆ checkAllDefined() [2/2]

bool freetensor::checkAllDefined ( const std::unordered_set< std::string > &  defs,
const std::unordered_set< std::string > &  namesInOp 
)
inline

◆ checkConflictId() [1/2]

void freetensor::checkConflictId ( const Func func)
inline

◆ checkConflictId() [2/2]

void freetensor::checkConflictId ( const Stmt ast)

◆ checkNotInLib()

void freetensor::checkNotInLib ( const Stmt ast,
const ID stmt 
)
inline

◆ checkNotModified() [1/2]

bool freetensor::checkNotModified ( const Stmt op,
const Expr expr,
CheckNotModifiedSide  s0Side,
const ID s0,
CheckNotModifiedSide  s1Side,
const ID s1 
)

Verify if expr evaluates to the same value in the period that AFTER ENCOUNTERING s0 UNTIL ENCOUNTERING THE NEXT s1. The exact boundary of the period to check can be set by s0Side and s1Side, to specify whether the period includes s0 and s1 themselves

It will return false in four cases:

  1. Any variable in expr is not defined at s0 or s1, or
  2. The defining VarDef or For nodes in s0 and s1 are different, or
  3. Any variable used in expr is written between s0 and s1, or
  4. Any variable used in expr is thread-local, but s0 and s1 do not share the same thread.

◆ checkNotModified() [2/2]

bool freetensor::checkNotModified ( const Stmt op,
const Expr s0Expr,
const Expr s1Expr,
CheckNotModifiedSide  s0Side,
const ID s0,
CheckNotModifiedSide  s1Side,
const ID s1 
)

Another version of checkNotModified that accpets two expressions, for s0 and s1, respectively

This version of checkNotModified is used when the iterators in the expression have different names in s0 and s1

TODO: Check the mapping of the iterators in a general way in checkNotModified. Currently it is checked explicitly in schedule/inline and pass/tensor_prop_const

◆ checkNotModifiedFastPreCheck() [1/2]

std::optional< bool > freetensor::checkNotModifiedFastPreCheck ( const Stmt op,
const Expr expr,
CheckNotModifiedSide  s0Side,
const ID s0,
CheckNotModifiedSide  s1Side,
const ID s1 
)

Fast preliminary screening of checkNotModified

It can optionally be used before checkNotModified. Parameters are the same.

◆ checkNotModifiedFastPreCheck() [2/2]

std::optional< bool > freetensor::checkNotModifiedFastPreCheck ( const Stmt op,
const Expr s0Expr,
const Expr s1Expr,
CheckNotModifiedSide  s0Side,
const ID s0,
CheckNotModifiedSide  s1Side,
const ID s1 
)

◆ checkVarCrossParallel()

void freetensor::checkVarCrossParallel ( const Stmt ast,
const ID def,
MemType  mtype 
)

◆ clearMarkVersion()

Stmt freetensor::clearMarkVersion ( const Stmt op)
inline

◆ coalesce() [1/2]

template<PBMapRef T>
PBMap freetensor::coalesce ( T &&  map)

◆ coalesce() [2/2]

template<PBSetRef T>
PBSet freetensor::coalesce ( T &&  set)

◆ codeGen()

NativeCode freetensor::codeGen ( const Func func,
const Ref< Target > &  target 
)

Generate native code

Parameters
func: The AST to be lowered. It must includes function signature to determine parameters and return values
target: The target architecture

◆ codeGenCPU()

NativeCode freetensor::codeGenCPU ( const Func func,
const Ref< Target > &  target 
)

Generate target function code

Returns
: source

◆ coefficients()

template<PBSetRef T>
PBSet freetensor::coefficients ( T &&  set,
int64_t  c = 0 
)

\in X, \Sigma c_i x_i \geq c$

Parameters
setthe input set
cthe RHS constant
Returns
PBSet set of valid coefficients for the input set

◆ commonCtx()

Ref< PBCtx > freetensor::commonCtx ( const auto &  lhs,
const auto &  rhs 
)

◆ compAccessBound()

AccessBound freetensor::compAccessBound ( const Stmt op,
const ID varDefId,
CompAccessBoundMode  mode = COMP_ACCESS_BOUND_ALL,
bool  includeTrivialBound = true,
const ID filterSubTree = ID() 
)

Compute the bound of all indices indexing a particular variable

Parameters
op: AST to be analyzed
varDefId: ID of the variable to be analyzed
mode: Choose to analyze read or write or both
includeTrivialBound: True to including lower_i = 0 and upper_i = len_i - 1 as trivial bounds. False to return nullptr if no non-trivial bound is found
filterSubTree: If set, consider only uses of the variable inside this sub-tree

◆ complement() [1/2]

template<PBMapRef T>
PBMap freetensor::complement ( T &&  map)

◆ complement() [2/2]

template<PBSetRef T>
PBSet freetensor::complement ( T &&  set)

◆ constFold() [1/2]

Expr freetensor::constFold ( const Expr op)
inline

◆ constFold() [2/2]

Stmt freetensor::constFold ( const Stmt op)
inline

Calculate constant (sub)expressions

For propagating constants among statements, please refer to pass/scalar_prop_const and pass/tensor_prop_const

◆ copyInfo()

template<class FromMap , class ToMap >
void freetensor::copyInfo ( const FromMap &  fromInfo,
const typename FromMap::key_type &  from,
ToMap &  toInfo,
const typename ToMap::key_type &  to 
)

◆ dedupTapeNames()

Stmt freetensor::dedupTapeNames ( const Stmt op,
const std::unordered_set< ID > &  tapes 
)

Make all VarDef nodes in tapes having globally unique names

◆ deepCopy() [1/8]

Expr freetensor::deepCopy ( const Expr op)

◆ deepCopy() [2/8]

Func freetensor::deepCopy ( const Func func)

◆ deepCopy() [3/8]

Ref< Buffer > freetensor::deepCopy ( const Ref< Buffer > &  b)
inline

◆ deepCopy() [4/8]

Ref< CutlassMicroKernelProperty > freetensor::deepCopy ( const Ref< CutlassMicroKernelProperty > &  p)
inline

◆ deepCopy() [5/8]

Ref< ForProperty > freetensor::deepCopy ( const Ref< ForProperty > &  _p)
inline

◆ deepCopy() [6/8]

Ref< ReductionItem > freetensor::deepCopy ( const Ref< ReductionItem > &  r)
inline

◆ deepCopy() [7/8]

Ref< Tensor > freetensor::deepCopy ( const Ref< Tensor > &  t)
inline

◆ deepCopy() [8/8]

Stmt freetensor::deepCopy ( const Stmt op)

◆ DEFINE_PASS_FOR_FUNC() [1/2]

freetensor::DEFINE_PASS_FOR_FUNC ( makeHeapAlloc  )

◆ DEFINE_PASS_FOR_FUNC() [2/2]

freetensor::DEFINE_PASS_FOR_FUNC ( refineSignDataType  )

◆ diff()

template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > freetensor::diff ( const std::unordered_set< T, Hash, KeyEqual > &  lhs,
const std::unordered_set< T, Hash, KeyEqual > &  rhs 
)

◆ dimFixVal()

PBVal freetensor::dimFixVal ( const PBSet set,
int  pos 
)
inline

◆ dimMaxVal()

template<PBSetRef T>
PBVal freetensor::dimMaxVal ( T &&  set,
int  pos 
)

◆ dimMinVal()

template<PBSetRef T>
PBVal freetensor::dimMinVal ( T &&  set,
int  pos 
)

◆ domain()

template<PBMapRef T>
PBSet freetensor::domain ( T &&  map)

◆ downCast() [1/3]

BaseDataType freetensor::downCast ( BaseDataType  lhs,
BaseDataType  rhs 
)

Intersect type

Obatin a new data type containing as few as possible values, where the value is of both of the input types. This is actually merging restrictions from both types.

◆ downCast() [2/3]

DataType freetensor::downCast ( const DataType lhs,
const DataType rhs 
)
inline

◆ downCast() [3/3]

SignDataType freetensor::downCast ( SignDataType  lhs,
SignDataType  rhs 
)

◆ dumpArray()

std::pair< std::string, std::string > freetensor::dumpArray ( const Ref< Array > &  array_)

The string is constructed as follow (Separated by space):

MetaData: {"ARR"} + {dtype} + {shape.size} + {shape[0]} + ... + {shape[shape.size - 1]}

Data: {Arraydata (string -> pybind11::bytes later, e.g. b'\x01\x23\xab\xcd')

The string is constructed as follow (Separated by space):

MetaData: {"ARR"} + {dtype} + {shape.size} + {shape[0]} + ... + {shape[shape.size - 1]}

Data: {Arraydata (string -> pybind11::bytes later, e.g. b'\x01\x23\xab\xcd')

◆ dumpAST()

std::string freetensor::dumpAST ( const AST op,
bool  dtypeInLoad = false,
bool  hexFloat = true 
)
inline

Serialize function for storing an AST and loading it back

◆ dumpDevice()

std::pair< std::string, std::string > freetensor::dumpDevice ( const Ref< Device > &  device_)

◆ dumpTarget()

std::pair< std::string, std::string > freetensor::dumpTarget ( const Ref< Target > &  target_)

◆ emptyMap()

template<PBSpaceRef T>
PBMap freetensor::emptyMap ( T &&  space)

◆ emptySet()

template<PBSpaceRef T>
PBSet freetensor::emptySet ( T &&  space)

◆ exceptSafeParallelFor()

template<std::integral T>
void freetensor::exceptSafeParallelFor ( begin,
end,
step,
const std::function< void(T)> &  body,
omp_sched_t  schedKind,
int  schedChunkSize = 0 
)

Wrapper for thread safe OpenMP parallel for

◆ filter()

template<class T , class U >
std::vector< T > freetensor::filter ( const std::vector< T > &  vec,
const U &  callback 
)

◆ findAllStmt() [1/5]

template<class T >
std::vector< Stmt > freetensor::findAllStmt ( const Func func,
const T &  filter 
)

◆ findAllStmt() [2/5]

std::vector< Stmt > freetensor::findAllStmt ( const Stmt ast,
const ID id 
)

Find all statements from an AST by ID, filter or selector

Returns
: All statements satisfying the given condition, in DFS pre order

◆ findAllStmt() [3/5]

std::vector< Stmt > freetensor::findAllStmt ( const Stmt ast,
const Ref< Selector > &  selector 
)

◆ findAllStmt() [4/5]

std::vector< Stmt > freetensor::findAllStmt ( const Stmt ast,
const std::function< bool(const Stmt &)> &  filter 
)

◆ findAllStmt() [5/5]

std::vector< Stmt > freetensor::findAllStmt ( const Stmt ast,
const std::string &  pattern 
)
inline

◆ findIndexingLoops()

std::unordered_map< For, std::vector< VarDef > > freetensor::findIndexingLoops ( const Stmt op)
inline

Find which which buffers is indexed by which loops

◆ findInnerMostScope()

int freetensor::findInnerMostScope ( const std::unordered_map< std::string, int > &  varScope,
const Expr op 
)

◆ findLoopVariance()

std::pair< LoopVariExprMap, LoopVariUniqVarMap > freetensor::findLoopVariance ( const Stmt op)

Check whether an expression or a variable is loop-variant

This function returns two map. The first map shows whether an expression is loop-variant, while the second map shows whether a variable is loop-variant. The result should be get by calling isVariant

NOTE: findLoopVariance currently treat expressions invariant to all their non-surrounding loops for minimize analyzing overhead, but it is possible to make this behaviour optional (see FindLoopVariance::visit(const Load &))

findLoopVariance runs an iterative algorithm. The variance info is expressed as a semi-lattice:

Invariant (implemented by inexistence in the resulting map)
|
Unknown (implemented by the `LoopVariability` type)
|
Variant (implemented by the `LoopVariability` type)
LoopVariability
Definition: find_loop_variance.h:13

All variabilities are initialized to Unkown, and will become either Invariant or Variant during iterations. The variability of an expression is the "meet" of its sub-expressions' variability. The variability of a variable is the "meet" of variability of all expressions stored to it

It is suggested to call pass/simplify before this function, to avoid false variants like i - i

◆ findStmt() [1/5]

template<class T >
Stmt freetensor::findStmt ( const Func func,
const T &  filter 
)

◆ findStmt() [2/5]

Stmt freetensor::findStmt ( const Stmt ast,
const ID id 
)

Find the only statement from an AST by ID, filter or selector

Returns
: The only statement
Exceptions
UnexpectedQueryResultif zero or more than one statements are found

◆ findStmt() [3/5]

Stmt freetensor::findStmt ( const Stmt ast,
const Ref< Selector > &  selector 
)

◆ findStmt() [4/5]

Stmt freetensor::findStmt ( const Stmt ast,
const std::function< bool(const Stmt &)> &  filter 
)

◆ findStmt() [5/5]

Stmt freetensor::findStmt ( const Stmt ast,
const std::string &  pattern 
)
inline

◆ findTapeOrRecompStmts()

std::pair< std::unordered_map< ID, std::unordered_set< ID > >, std::unordered_map< ID, std::unordered_set< ID > > > freetensor::findTapeOrRecompStmts ( const Stmt op,
const std::unordered_set< ID > &  defsToTape,
const std::unordered_set< ID defsNeedGrad,
std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &  derivatives 
)

Given a set of variables that we are willing to tape, find out all the statements we need to tape, and all the statements we need to recompute

Returns
: ({ID of VarDef -> IDs of statements to tape}, {ID of VarDef -> IDs of statements to recompute})

◆ fission()

std::pair< Stmt, std::pair< std::unordered_map< ID, ID >, std::unordered_map< ID, ID > > > freetensor::fission ( const Stmt ast,
const ID loop,
FissionSide  side,
const ID splitter,
bool  allowEnlarge,
const std::string &  suffix0,
const std::string &  suffix1 
)

◆ fixDim()

template<PBSetRef T>
PBSet freetensor::fixDim ( T &&  set,
unsigned  pos,
int  x 
)

◆ fixInputDim()

template<PBMapRef T>
PBMap freetensor::fixInputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ fixOutputDim()

template<PBMapRef T>
PBMap freetensor::fixOutputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ flatten()

template<PBSetRef T>
PBSet freetensor::flatten ( T &&  set)

◆ flattenDomain()

template<PBMapRef T>
PBMap freetensor::flattenDomain ( T &&  map)

◆ flattenMapToSet()

template<PBMapRef T>
PBSet freetensor::flattenMapToSet ( T &&  map)

◆ flattenRange()

template<PBMapRef T>
PBMap freetensor::flattenRange ( T &&  map)

◆ flattenStmtSeq()

Stmt freetensor::flattenStmtSeq ( const Stmt op)
inline

Merge nested StmtSeq nodes into one

Empty VarDef nodes that do not output, For, If or Assert nodes will be removed

This pass also clears Assume nodes (even if they are not empty)

◆ floatSimplify()

Stmt freetensor::floatSimplify ( const Stmt op)

Simplify floating-point expressions in an AST

This pass is by-passed when Config::fastMath is unset

◆ floorDiv() [1/3]

LowerBound freetensor::floorDiv ( const LowerBound b,
int  k 
)

◆ floorDiv() [2/3]

UpperBound freetensor::floorDiv ( const UpperBound b,
int  k 
)

◆ floorDiv() [3/3]

auto freetensor::floorDiv ( IntegralExceptBool auto  a,
IntegralExceptBool auto  b 
)
inline

◆ fuse()

std::pair< Stmt, ID > freetensor::fuse ( const Stmt ast,
const ID loop0,
const ID loop1,
bool  strict 
)

◆ GET_ISL_PTR()

template<class T >
T * freetensor::GET_ISL_PTR ( T *  ptr)

◆ getIDFromPack()

template<typename... Args>
auto freetensor::getIDFromPack ( const std::tuple< Args... > &  args)

◆ getMetadataFromPack()

template<typename... Args>
auto freetensor::getMetadataFromPack ( const std::tuple< Args... > &  args)

◆ getNewName()

std::string freetensor::getNewName ( const std::string &  oldName,
const std::unordered_set< std::string > &  used 
)

◆ getPackFromID()

template<typename... Args>
auto freetensor::getPackFromID ( auto  schedule,
const std::tuple< Args... > &  args 
)

◆ getRangeFromStmtSeq()

std::optional< std::pair< ID, ID > > freetensor::getRangeFromStmtSeq ( const Stmt op,
const std::unordered_set< ID > &  stmts 
)

◆ gradBody()

std::tuple< Stmt, Stmt, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string >, std::unordered_map< ID, std::string > > freetensor::gradBody ( const Stmt op,
const std::unordered_set< std::string > &  _requires,
const std::unordered_set< std::string > &  provides,
const TapeStrategy tapes,
bool  resetProvidedGrad = true,
bool  invert = false,
const std::vector< StmtSetToUserGrad > &  userGrads = {} 
)

Reverse mode automatic differentiation

Parameters
op: (For gradBody) Original AST
op: (For gradFuncInplace and gradFuncOutOfPlace) Original function
requires: Name of input variables that need gradients
provides: Name of output variables whose gradients are known
tapes: VarDef IDs of intermediate variables that need to be stored in the forward pass
tapeInClosure: (For gradFuncInplace and gradFuncOutOfPlace) True to pass taped tensors from the forward function to the backward function in implicit I/O parameters, i.e. in closure. False to pass these tensors as explicit I/O parameters. Default to true
resetProvidedGrad: If true, reset gradients for all variables in provides to 0 after use. This ensures the final result is correct when computing gradients of a program part by part with multiple calls to this function. If false, do not touch the provided gradient, which makes it convenient to run for multiple rounds for timing.
invert(Experimental) If set to true, it can reduce the amount of recomputation or taping required. However, this may result in a loss of precision for floating-point numbers. Defaults to true.
userGrads: For custom gradients. Each StmtSetToUserGrad item in the list specifies a statement range in the original program, which should be replaced by a backward statement
Returns
: ( Forward AST Backward AST, Mapping from names in requries to its gradient name, Mapping from names in provides to its gradient name Mapping from VarDef IDs of intermediate variables being stored to its corresponding output names )

◆ gradFuncInplace()

std::tuple< Func, Func, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string > > freetensor::gradFuncInplace ( const Func func,
const std::unordered_set< std::string > &  _requires,
const std::unordered_set< std::string > &  provides,
const TapeStrategy tapes,
bool  tapeInClosure = true,
bool  resetProvidedGrad = true,
bool  invert = false,
const std::vector< StmtSetToUserGrad > &  userGrads = {} 
)

◆ gradFuncOutOfPlace()

std::tuple< Func, Func, std::unordered_map< std::string, std::string >, std::unordered_map< std::string, std::string > > freetensor::gradFuncOutOfPlace ( const Func func,
const std::unordered_set< std::string > &  _requires,
const std::unordered_set< std::string > &  provides,
const TapeStrategy tapes,
bool  tapeInClosure = true,
bool  resetProvidedGrad = true,
bool  invert = false,
const std::vector< StmtSetToUserGrad > &  userGrads = {} 
)

◆ hashCombine()

size_t freetensor::hashCombine ( size_t  seed,
size_t  other 
)

◆ hasIdenticalCoeff()

template<class T >
bool freetensor::hasIdenticalCoeff ( const LinearExpr< T > &  lhs,
const LinearExpr< T > &  rhs 
)

◆ hasIntersect()

template<class T , class Hash , class KeyEqual >
bool freetensor::hasIntersect ( const std::unordered_set< T, Hash, KeyEqual > &  lhs,
const std::unordered_set< T, Hash, KeyEqual > &  rhs 
)

◆ hoistReturnVars()

Func freetensor::hoistReturnVars ( const Func func)

◆ hoistSelectedVar() [1/2]

Stmt freetensor::hoistSelectedVar ( const Stmt op,
const Ref< Selector > &  selector 
)

◆ hoistSelectedVar() [2/2]

Stmt freetensor::hoistSelectedVar ( const Stmt op,
const std::string &  selector 
)

Hoist all selected VarDef nodes untill they can no longer be selected by the selector

You only need to describe an area in the selector. No need to limit the node type to be VarDef

Algorithm: Each time we hoist all selected nodes over its direct parent (so relative position of each VarDef nodes will be kept intact). Repeat until convergance

Parameters
selector: Hoist all VarDef nodes in this area
Exceptions
InvalidScheduleif the hoisting is impossible

◆ hoistVarOverStmtSeq()

Stmt freetensor::hoistVarOverStmtSeq ( const Stmt op,
const std::optional< std::vector< ID > > &  togetherIds = std::nullopt 
)

Transform things like VarDef { stmt0 VarDef { stmt1 }} into VarDef { VarDef { stmt0 stmt1 }}

This is not a optimization pass. It is intended to used inside other passes and make them simpler. It is suggest to run sinkVar after these passes to revert the effect of hoistVarOverStmtSeq

  • hoistVarOverStmtSeq(op): Hoist all VarDefs if possbile
  • hoistVarOverStmtSeq(op, togetherIds): Hoist some VarDefs to make all statements in togetherIds are in the same VarDefs, while leaving other VarDefs untouched

◆ identity()

template<PBSpaceRef T>
PBMap freetensor::identity ( T &&  space)

◆ inlinedInvoke()

Stmt freetensor::inlinedInvoke ( const Metadata callSiteMetadata,
const Func func,
const std::vector< Ref< FrontendVar > > &  args,
const std::unordered_map< std::string, Ref< FrontendVar > > &  kvs,
const std::vector< std::string > &  retNames,
const std::unordered_set< std::string > &  conflictNames,
bool  forceAllowClosures = false 
)

Replace a Function's all arguments by FrontendVars and return a Stmt

Usually we handle function calls directly in the frontend. But sometimes we may want to call a differentiated function, which is already lowered as an AST. Then, we can use inlinedInvoke to call it

Parameters
callSiteMetadata: Metadata marked for the call site
func: Function to invoke
args: Positional arguments
kvs: Keyword arguments
retNames: Catch return values in these names, in the same order as in func
conflictNames: Avoiding using these names in the inlined statements
forceAllowClosures: Allow closures in the callee function. Please be sure to redirect closures in the caller properly

◆ inlining()

Stmt freetensor::inlining ( const Stmt ast,
const ID def 
)

◆ insertDims()

template<PBSetRef T>
PBSet freetensor::insertDims ( T &&  set,
unsigned  first,
unsigned  n 
)

◆ insertInputDims()

template<PBMapRef T>
PBMap freetensor::insertInputDims ( T &&  map,
unsigned  first,
unsigned  n 
)

◆ insertOutputDims()

template<PBMapRef T>
PBMap freetensor::insertOutputDims ( T &&  map,
unsigned  first,
unsigned  n 
)

◆ intersect() [1/5]

template<class T , class V1 , class V2 , class Hash , class KeyEqual >
std::unordered_map< T, std::pair< V1, V2 >, Hash, KeyEqual > freetensor::intersect ( const std::unordered_map< T, V1, Hash, KeyEqual > &  lhs,
const std::unordered_map< T, V2, Hash, KeyEqual > &  rhs 
)

◆ intersect() [2/5]

template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > freetensor::intersect ( const std::unordered_set< T, Hash, KeyEqual > &  lhs,
const std::unordered_set< T, Hash, KeyEqual > &  rhs 
)

◆ intersect() [3/5]

template<class T >
std::vector< T > freetensor::intersect ( const std::vector< T > &  lhs,
const std::vector< T > &  rhs 
)

◆ intersect() [4/5]

template<PBMapRef T, PBMapRef U>
PBMap freetensor::intersect ( T &&  lhs,
U &&  rhs 
)

◆ intersect() [5/5]

template<PBSetRef T, PBSetRef U>
PBSet freetensor::intersect ( T &&  lhs,
U &&  rhs 
)

◆ intersectDomain() [1/3]

template<PBMapRef T, PBSetRef U>
PBMap freetensor::intersectDomain ( T &&  lhs,
U &&  rhs 
)

◆ intersectDomain() [2/3]

template<PBSingleFuncRef T, PBSetRef U>
PBSingleFunc freetensor::intersectDomain ( T &&  lhs,
U &&  rhs 
)

◆ intersectDomain() [3/3]

template<PBFuncRef T, PBSetRef U>
PBFunc freetensor::intersectDomain ( T &&  lhs,
U &&  rhs 
)

◆ intersectParams() [1/2]

template<PBSetRef T, PBSetRef U>
PBSet freetensor::intersectParams ( T &&  lhs,
U &&  rhs 
)

◆ intersectParams() [2/2]

template<PBMapRef T, PBSetRef U>
PBMap freetensor::intersectParams ( T &&  lhs,
U &&  rhs 
)

◆ intersectRange()

template<PBMapRef T, PBSetRef U>
PBMap freetensor::intersectRange ( T &&  lhs,
U &&  rhs 
)

◆ invertStmts()

std::tuple< Stmt, std::unordered_map< ID, InversionInfo > > freetensor::invertStmts ( const Stmt op,
std::unordered_map< ID, std::unordered_set< ID > > *  idsNeeded,
std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > *  derivatives 
)

Given a set of statements we want to get their value in the backward pass, try to recover as more as possbile of them by inverting statements that overwrites them. The rest of the statements have to be recomputed in the traditional way.

Parameters
op: The AST
idsNeeded: {ID of VarDef -> IDs of statements to tape or recompute}. This parameter is updated in place
derivatives: Map generated by autograd/derivative.h, updated in place here
Returns
: (A modified AST for version analysis, {ID -> inversion})

◆ isBool() [1/2]

bool freetensor::isBool ( BaseDataType  dtype)

◆ isBool() [2/2]

bool freetensor::isBool ( const DataType dtype)
inline

◆ isEQ0() [1/2]

bool freetensor::isEQ0 ( const DataType dtype)
inline

◆ isEQ0() [2/2]

bool freetensor::isEQ0 ( SignDataType  dtype)

◆ isFloat() [1/2]

bool freetensor::isFloat ( BaseDataType  dtype)

◆ isFloat() [2/2]

bool freetensor::isFloat ( const DataType dtype)
inline

◆ isGE0() [1/2]

bool freetensor::isGE0 ( const DataType dtype)
inline

◆ isGE0() [2/2]

bool freetensor::isGE0 ( SignDataType  dtype)

◆ isGT0() [1/2]

bool freetensor::isGT0 ( const DataType dtype)
inline

◆ isGT0() [2/2]

bool freetensor::isGT0 ( SignDataType  dtype)

◆ isInputting()

bool freetensor::isInputting ( AccessType  atype)
inline

◆ isInt() [1/2]

bool freetensor::isInt ( BaseDataType  dtype)

◆ isInt() [2/2]

bool freetensor::isInt ( const DataType dtype)
inline

◆ isLE0() [1/2]

bool freetensor::isLE0 ( const DataType dtype)
inline

◆ isLE0() [2/2]

bool freetensor::isLE0 ( SignDataType  dtype)

◆ isLT0() [1/2]

bool freetensor::isLT0 ( const DataType dtype)
inline

◆ isLT0() [2/2]

bool freetensor::isLT0 ( SignDataType  dtype)

◆ isNE0() [1/2]

bool freetensor::isNE0 ( const DataType dtype)
inline

◆ isNE0() [2/2]

bool freetensor::isNE0 ( SignDataType  dtype)

◆ isNumber() [1/2]

bool freetensor::isNumber ( BaseDataType  dtype)
inline

◆ isNumber() [2/2]

bool freetensor::isNumber ( const DataType dtype)
inline

◆ isOutputting()

bool freetensor::isOutputting ( AccessType  atype)
inline

◆ isSameTarget()

bool freetensor::isSameTarget ( const Ref< Target > &  lhs,
const Ref< Target > &  rhs 
)

◆ isSubset() [1/2]

bool freetensor::isSubset ( const PBMap small,
const PBMap big 
)
inline

◆ isSubset() [2/2]

bool freetensor::isSubset ( const PBSet small,
const PBSet big 
)
inline

◆ isSubSetOf()

template<class T , class Hash , class KeyEqual >
bool freetensor::isSubSetOf ( const std::unordered_set< T, Hash, KeyEqual > &  lhs,
const std::unordered_set< T, Hash, KeyEqual > &  rhs 
)

◆ isVariant() [1/3]

bool freetensor::isVariant ( const LoopVariExprMap exprInfo,
const StmtOrExprID expr,
const ID loop 
)

◆ isVariant() [2/3]

bool freetensor::isVariant ( const LoopVariUniqVarMap varInfo,
const ID defId,
const ID loop 
)

◆ isVariant() [3/3]

bool freetensor::isVariant ( const LoopVariUniqVarMap varInfo,
const VarDef def,
const ID loop 
)

◆ isWritable()

bool freetensor::isWritable ( AccessType  atype)
inline

◆ join() [1/2]

auto freetensor::join ( const std::string &  splitter)
inline

◆ join() [2/2]

template<std::ranges::range Container>
std::string freetensor::join ( Container &&  c,
const std::string &  splitter 
)

◆ Lazy()

template<typename F >
freetensor::Lazy ( delayedInit) -> Lazy< std::decay_t< decltype(std::declval< F >()())> >

◆ lca()

Ref< ASTPart > freetensor::lca ( const Ref< ASTPart > &  lhs,
const Ref< ASTPart > &  rhs 
)

Lowest common ancestor

◆ lcaAST()

AST freetensor::lcaAST ( const AST lhs,
const AST rhs 
)

◆ lcaExpr()

Expr freetensor::lcaExpr ( const Expr lhs,
const Expr rhs 
)

◆ lcaStmt()

Stmt freetensor::lcaStmt ( const Stmt lhs,
const Stmt rhs 
)

◆ lexGE()

template<PBSpaceRef T>
PBMap freetensor::lexGE ( T &&  space)

◆ lexGT()

template<PBSpaceRef T>
PBMap freetensor::lexGT ( T &&  space)

◆ lexLE()

template<PBSpaceRef T>
PBMap freetensor::lexLE ( T &&  space)

◆ lexLT()

template<PBSpaceRef T>
PBMap freetensor::lexLT ( T &&  space)

◆ lexmax() [1/2]

template<PBMapRef T>
PBMap freetensor::lexmax ( T &&  map)

◆ lexmax() [2/2]

template<PBSetRef T>
PBSet freetensor::lexmax ( T &&  set)

◆ lexmin() [1/2]

template<PBMapRef T>
PBMap freetensor::lexmin ( T &&  map)

◆ lexmin() [2/2]

template<PBSetRef T>
PBSet freetensor::lexmin ( T &&  set)

◆ lin2bounds()

template<class T >
std::pair< std::optional< LowerBound >, std::optional< UpperBound > > freetensor::lin2bounds ( const LinearExpr< T > &  _lin,
ASTNodeType  cmp,
const Expr x 
)

Dirive the bound of "x" in a "LINEAR(x) OP 0"

E.g. convert "2 * x + 3 * y > 0" to x > -3/2 * y"

◆ lin2expr()

template<class T >
requires std::integral<T> || std::floating_point<T>
Expr freetensor::lin2expr ( const LinearExpr< T > &  lin)

Generate an expression from a LinearExpr

This function is only applied to fundamental types. For LinearExpr<Rational<T>>, see bounds.cc, because there are different rounding directinos

◆ linear()

LinearExpr< int64_t > freetensor::linear ( const Expr expr)

Try to represent each (sub)expression as a linear expression of memory accesses and loop iterators

◆ linearComp()

std::optional< std::pair< LinearExpr< int64_t >, ASTNodeType > > freetensor::linearComp ( const Expr expr)

Try to represent an comparison as a "LINEAR OP 0" form

◆ loadArray()

Ref< Array > freetensor::loadArray ( const std::string &  txt,
const std::string &  data 
)

◆ loadAST()

AST freetensor::loadAST ( const std::string &  txt)

◆ loadDevice()

Ref< Device > freetensor::loadDevice ( const std::string &  txt,
const std::string &  data 
)

DEV <Num> <Target> e.g. DEV 3 GPU 1

DEV <Num> <Target> e.g. DEV 3 GPU 1

◆ loadTarget()

Ref< Target > freetensor::loadTarget ( const std::string &  txt,
const std::string &  data 
)

◆ logger()

Logger freetensor::logger ( )
inline

◆ lower()

template<class T >
T freetensor::lower ( const T &  _ast,
const Ref< Target > &  _target = nullptr,
const std::unordered_set< std::string > &  skipPasses = {},
int  verbose = 0 
)

Lower an AST using a series of passes

Parameters
ast: The AST to be lowered. Can be a Func or a Stmt
target: Lower the AST to a target with target-specific passes, then the AST can be used for codegen. If not set, use the default Target in Config
skipPasses: Skip some pass for testing or debugging. Names in skipPasses are in underscore_style, as in Python. Please note that some passes will not be skipped even specified in these parameter, because they are indirectly called in some other passes
verbose: 0 = print nothing. 1 = print the lowered AST. 2 = print AST after every single passes

◆ lowerBoundDim()

template<PBSetRef T>
PBSet freetensor::lowerBoundDim ( T &&  set,
unsigned  pos,
int  x 
)

◆ lowerBoundInputDim()

template<PBMapRef T>
PBMap freetensor::lowerBoundInputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ lowerBoundOutputDim()

template<PBMapRef T>
PBMap freetensor::lowerBoundOutputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ lowerCutlassMicroBlock()

Stmt freetensor::lowerCutlassMicroBlock ( const Stmt ast,
const ID matMulId,
const ID defIdC,
const std::vector< bool > &  dimsCBatch,
const std::vector< bool > &  dimsCM,
const std::vector< bool > &  dimsCN 
)

◆ makeAbs()

template<class T >
Expr freetensor::makeAbs ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeAdd()

template<class T , class U >
Expr freetensor::makeAdd ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeAlloc()

Stmt freetensor::makeAlloc ( const std::string &  var,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeAny()

Stmt freetensor::makeAny ( std::source_location  loc = std::source_location::current())
inline

◆ makeAnyExpr()

Expr freetensor::makeAnyExpr ( std::source_location  loc = std::source_location::current())
inline

◆ makeAssert()

template<class Tcond , class Tbody >
Stmt freetensor::makeAssert ( Tcond &&  cond,
Tbody &&  body,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeAssume()

template<class Tcond , class Tbody >
Stmt freetensor::makeAssume ( Tcond &&  cond,
Tbody &&  body,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeBinary()

template<class T , class U >
Expr freetensor::makeBinary ( ASTNodeType  nodeType,
T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeBoolConst()

Expr freetensor::makeBoolConst ( bool  val,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeBuffer()

template<class T >
Ref< Buffer > freetensor::makeBuffer ( T &&  tensor,
AccessType  atype,
MemType  mtype 
)

◆ makeCast()

template<class T >
Expr freetensor::makeCast ( T &&  expr,
DataType  destType,
std::source_location  loc = std::source_location::current() 
)

◆ makeCeil()

template<class T >
Expr freetensor::makeCeil ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeCeilDiv()

template<class T , class U >
Expr freetensor::makeCeilDiv ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeCos()

template<class T >
Expr freetensor::makeCos ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeEQ()

template<class T , class U >
Expr freetensor::makeEQ ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeEval()

template<class T >
Stmt freetensor::makeEval ( T &&  expr,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeExp()

template<class T >
Expr freetensor::makeExp ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeFloatConst()

Expr freetensor::makeFloatConst ( double  val,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeFloor()

template<class T >
Expr freetensor::makeFloor ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeFloorDiv()

template<class T , class U >
Expr freetensor::makeFloorDiv ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeFor()

template<class Tbegin , class Tend , class Tstep , class Tlen , class Tbody , class Tproperty >
Stmt freetensor::makeFor ( const std::string &  iter,
Tbegin &&  begin,
Tend &&  end,
Tstep &&  step,
Tlen &&  len,
Tproperty &&  property,
Tbody &&  body,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeFree()

Stmt freetensor::makeFree ( const std::string &  var,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeFunc() [1/2]

template<class Tbody >
Func freetensor::makeFunc ( const std::string &  name,
const std::vector< FuncParam > &  params,
const std::vector< FuncRet > &  returns,
Tbody &&  body 
)

◆ makeFunc() [2/2]

template<class Tbody , class Tparams , class Treturns , class Tclosure >
Func freetensor::makeFunc ( const std::string &  name,
Tparams &&  params,
Treturns &&  returns,
Tbody &&  body 
)

◆ makeGE()

template<class T , class U >
Expr freetensor::makeGE ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeGT()

template<class T , class U >
Expr freetensor::makeGT ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeHeapAlloc()

Stmt freetensor::makeHeapAlloc ( const Stmt op)

Insert Alloc and Free node for heap-allocated varialbes, and turn stack-allocated variables to heap-allocated is beneficial

Varaibles with MemType::CPUHeap or MemType::GPUGlobalHeap are allocated on the heap by some allocators. Other variables are allocated in a stack manner, not allocated by an allocator, but they may also be on the heap physically

Dynamic-sized variables cannot be allocated on the stack, so turn them to be allocated on the heap

For other variables, if we can delay its allocation or free them earlier, we allocate them on the heap. The delation or making early will not cross any control flow

This transformation is not applied to scalars

◆ makeIf() [1/2]

template<class Tcond , class Tthen , class Telse = std::nullptr_t>
Stmt freetensor::makeIf ( Tcond &&  cond,
Tthen &&  thenCase,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeIf() [2/2]

template<class Tcond , class Tthen , class Telse = std::nullptr_t>
Stmt freetensor::makeIf ( Tcond &&  cond,
Tthen &&  thenCase,
Telse &&  elseCase,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeIfExpr()

template<class T , class U , class V >
Expr freetensor::makeIfExpr ( T &&  cond,
U &&  thenCase,
V &&  elseCase,
std::source_location  loc = std::source_location::current() 
)

◆ makeIntConst()

Expr freetensor::makeIntConst ( int64_t  val,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeIntrinsic() [1/2]

Expr freetensor::makeIntrinsic ( const std::string &  format,
std::initializer_list< Expr params,
DataType  retType,
bool  hasSideEffect,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeIntrinsic() [2/2]

template<class T >
Expr freetensor::makeIntrinsic ( const std::string &  format,
T &&  params,
DataType  retType,
bool  hasSideEffect,
std::source_location  loc = std::source_location::current() 
)

◆ makeLAnd()

template<class T , class U >
Expr freetensor::makeLAnd ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeLE()

template<class T , class U >
Expr freetensor::makeLE ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeLn()

template<class T >
Expr freetensor::makeLn ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeLNot()

template<class T >
Expr freetensor::makeLNot ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeLoad() [1/2]

Expr freetensor::makeLoad ( const std::string &  var,
const std::vector< Expr > &  indices,
DataType  loadType,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeLoad() [2/2]

template<class Tindices >
Expr freetensor::makeLoad ( const std::string &  var,
Tindices &&  indices,
DataType  loadType,
std::source_location  loc = std::source_location::current() 
)

◆ makeLoadAtVersion() [1/2]

Expr freetensor::makeLoadAtVersion ( const std::string &  tapeName,
const std::vector< Expr > &  indices,
const DataType  loadType,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeLoadAtVersion() [2/2]

template<class Tindices >
Expr freetensor::makeLoadAtVersion ( const std::string &  tapeName,
Tindices &&  indices,
const DataType  loadType,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeLOr()

template<class T , class U >
Expr freetensor::makeLOr ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeLOrLAnd()

Expr freetensor::makeLOrLAnd ( const std::vector< std::vector< Expr > > &  exprs)

Make l_or(l_and(...), l_and(...), ...) and remove duplications

Parameters
exprs: Vector of vector or exprs. Items of inner ones are combined with l_and. Items of the outer one are combined with l_or.
Returns
: Result expression. Always non-null.

◆ makeLT()

template<class T , class U >
Expr freetensor::makeLT ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeMarkVersion()

Stmt freetensor::makeMarkVersion ( const std::string &  tapeName,
const std::string &  var,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeMatMul()

Stmt freetensor::makeMatMul ( MatMulBackend  backend,
const Ref< CutlassMicroKernelProperty > &  cutlassMicroKernelProperty,
const Expr a,
const Expr b,
const Expr c,
const Expr alpha,
const Expr beta,
const Expr m,
const Expr k,
const Expr n,
const Expr lda,
const Expr ldb,
const Expr ldc,
const Expr stridea,
const Expr strideb,
const Expr stridec,
const Expr batchSize,
bool  aIsRowMajor,
bool  bIsRowMajor,
bool  cIsRowMajor,
const Stmt equivalent,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeMax()

template<class T , class U >
Expr freetensor::makeMax ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeMaxMin()

template<typename T , typename U >
Expr freetensor::makeMaxMin ( const std::vector< std::vector< Expr > > &  exprs,
const T &  negInf,
const U &  inf 
)

Make max(min(...), min(...), ...) and remove duplications

Parameters
exprs: Vector of vector or exprs. Items of inner ones are combined with min. Items of the outer one are combined with max.
negInf: Expr or function returning an Expr. What to return in case of the max term is empty. Can be nullptr.
inf: Expr or function returning an Expr. What to return in case of any in term is empty. Can be nullptr.
Returns
: Result expression. Always non-null.

◆ makeMaxMinImpl()

Expr freetensor::makeMaxMinImpl ( const std::vector< std::vector< Expr > > &  exprs,
const std::function< Expr()> &  inf,
const std::function< Expr()> &  negInf 
)

◆ makeMetadata() [1/4]

AnonymousMetadata freetensor::makeMetadata ( const ID id = {})

◆ makeMetadata() [2/4]

TransformedMetadata freetensor::makeMetadata ( const std::string &  op,
const std::vector< Metadata > &  sources 
)

◆ makeMetadata() [3/4]

template<typename... Srcs>
requires (std::convertible_to<Srcs, Stmt> && ...)
auto freetensor::makeMetadata ( const std::string &  op,
Srcs &&...  sourceStmts 
)

Construct TransformedMetadata with specified operation and source Stmts.

The children Metadatas are retrieved from the provided Stmts.

Parameters
opoperation of the TransformedMetadata
sourceStmtsvariadic parameters that accept the source Stmts.

◆ makeMetadata() [4/4]

SourceMetadata freetensor::makeMetadata ( const std::vector< std::string > &  labels,
const std::optional< std::pair< std::string, int > > &  location,
const Metadata callerMetadata 
)

◆ makeMin()

template<class T , class U >
Expr freetensor::makeMin ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeMinMax()

template<typename T , typename U >
Expr freetensor::makeMinMax ( const std::vector< std::vector< Expr > > &  exprs,
const T &  inf,
const U &  negInf 
)

Make min(max(...), max(...), ...) and remove duplications

Parameters
exprs: Vector of vector or exprs. Items of inner ones are combined with max. Items of the outer one are combined with min.
inf: Expr or function returning an Expr. What to return in case of the min term is empty. Can be nullptr.
negInf: Expr or function returning an Expr. What to return in case of any max term is empty. Can be nullptr.
Returns
: Result expression. Always non-null.

◆ makeMinMaxImpl()

Expr freetensor::makeMinMaxImpl ( const std::vector< std::vector< Expr > > &  exprs,
const std::function< Expr()> &  inf,
const std::function< Expr()> &  negInf 
)

◆ makeMod()

template<class T , class U >
Expr freetensor::makeMod ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeMul()

template<class T , class U >
Expr freetensor::makeMul ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeNE()

template<class T , class U >
Expr freetensor::makeNE ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeNestedLoops()

template<class Titers , class Tbegins , class Tends , class Tsteps , class Tlens , class Tproperties , class Tbody >
Stmt freetensor::makeNestedLoops ( Titers &&  iters,
Tbegins &&  begins,
Tends &&  ends,
Tsteps &&  steps,
Tlens &&  lens,
Tproperties &&  properties,
Tbody &&  body 
)

Helper function to make a loop nest given lists of loop parameters (from outer to inner)

Element of iters can be std::string, or Expr that can be casted to Var

Pass nullptr ends or lens to set it automatically

◆ makeParallelReduction()

Stmt freetensor::makeParallelReduction ( const Stmt op,
const Ref< Target > &  target 
)

Find all racing ReduceTo nodes, and implement them in a parallel way

If all ReduceTo nodes in a parallel for all reduce into a loop-invariant possition, we will use a race-free implementation. Otherwise, we will use synchronized (including atomic) operations.

Parameters
target: Target information. Can be null for target-agnostic debugging

◆ makeRealDiv()

template<class T , class U >
Expr freetensor::makeRealDiv ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeReduceTo() [1/2]

template<class Texpr >
Stmt freetensor::makeReduceTo ( const std::string &  var,
const std::vector< Expr > &  indices,
ReduceOp  op,
Texpr &&  expr,
bool  sync,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeReduceTo() [2/2]

template<class Tindices , class Texpr >
Stmt freetensor::makeReduceTo ( const std::string &  var,
Tindices &&  indices,
ReduceOp  op,
Texpr &&  expr,
bool  sync,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeReduction() [1/2]

Stmt freetensor::makeReduction ( const Stmt op)
inline

◆ makeReduction() [2/2]

Stmt freetensor::makeReduction ( const Stmt op,
const std::unordered_set< ReduceOp > &  types,
bool  canonicalOnly = false 
)
inline

Transform things like a = a + b into a += b

This is to make the dependence analysis more accurate

Parameters
types: Only transform these types of reductions
canonicalOnly: True to avoid cyclic reductions like a += a + b

◆ makeReductionItem()

template<class Tbegins , class Tends >
Ref< ReductionItem > freetensor::makeReductionItem ( ReduceOp  op,
const std::string &  var,
Tbegins &&  begins,
Tends &&  ends,
bool  syncFlush 
)

◆ makeRemainder()

template<class T , class U >
Expr freetensor::makeRemainder ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeRoundTowards0Div()

template<class T , class U >
Expr freetensor::makeRoundTowards0Div ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeSigmoid()

template<class T >
Expr freetensor::makeSigmoid ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeSin()

template<class T >
Expr freetensor::makeSin ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeSqrt()

template<class T >
Expr freetensor::makeSqrt ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeSquare()

template<class T >
Expr freetensor::makeSquare ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeStmtSeq() [1/2]

Stmt freetensor::makeStmtSeq ( std::initializer_list< Stmt stmts,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeStmtSeq() [2/2]

template<class Tstmts >
Stmt freetensor::makeStmtSeq ( Tstmts &&  stmts,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeStore() [1/2]

template<class Texpr >
Stmt freetensor::makeStore ( const std::string &  var,
const std::vector< Expr > &  indices,
Texpr &&  expr,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeStore() [2/2]

template<class Tindices , class Texpr >
Stmt freetensor::makeStore ( const std::string &  var,
Tindices &&  indices,
Texpr &&  expr,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ makeSub()

template<class T , class U >
Expr freetensor::makeSub ( T &&  lhs,
U &&  rhs,
std::source_location  loc = std::source_location::current() 
)

◆ makeTan()

template<class T >
Expr freetensor::makeTan ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeTanh()

template<class T >
Expr freetensor::makeTanh ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeTensor() [1/2]

Ref< Tensor > freetensor::makeTensor ( std::initializer_list< Expr shape,
DataType  dtype 
)
inline

◆ makeTensor() [2/2]

template<class T >
Ref< Tensor > freetensor::makeTensor ( T &&  shape,
DataType  dtype 
)

◆ makeUnary()

template<class T >
Expr freetensor::makeUnary ( ASTNodeType  nodeType,
T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeUnbound()

template<class T >
Expr freetensor::makeUnbound ( T &&  expr,
std::source_location  loc = std::source_location::current() 
)

◆ makeVar()

Expr freetensor::makeVar ( const std::string &  name,
std::source_location  loc = std::source_location::current() 
)
inline

◆ makeVarDef()

template<class Tbuffer , class Tbody >
Stmt freetensor::makeVarDef ( const std::string &  name,
Tbuffer &&  buffer,
const std::optional< std::string > &  viewOf,
Tbody &&  body,
bool  pinned,
const Metadata metadata = nullptr,
const ID id = {},
std::source_location  loc = std::source_location::current() 
)

◆ mangle()

std::string freetensor::mangle ( const std::string &  name)

◆ manipMetadataMultiLine()

std::ostream & freetensor::manipMetadataMultiLine ( std::ostream &  os)

◆ manipMetadataNoId()

std::ostream & freetensor::manipMetadataNoId ( std::ostream &  os)

◆ manipMetadataOneLine()

std::ostream & freetensor::manipMetadataOneLine ( std::ostream &  os)

◆ manipMetadataPrintId()

std::ostream & freetensor::manipMetadataPrintId ( std::ostream &  os)

◆ manipMetadataSkipLocation()

std::ostream & freetensor::manipMetadataSkipLocation ( std::ostream &  os)

◆ manipMetadataWithLocation()

std::ostream & freetensor::manipMetadataWithLocation ( std::ostream &  os)

◆ manipNoIdSign()

std::function< std::ostream &(std::ostream &)> freetensor::manipNoIdSign ( bool  flag)

◆ manipNoPrettyAST()

std::function< std::ostream &(std::ostream &)> freetensor::manipNoPrettyAST ( bool  flag)

◆ match()

bool freetensor::match ( const Stmt pattern,
const Stmt instance 
)

◆ max()

template<PBSingleFuncRef T, PBSingleFuncRef U>
PBSingleFunc freetensor::max ( T &&  lhs,
U &&  rhs 
)

◆ meetTo()

template<class FromMap , class ToMap >
void freetensor::meetTo ( const FromMap &  fromInfo,
const typename FromMap::key_type &  from,
ToMap &  toInfo,
const typename ToMap::key_type &  to 
)

◆ merge()

std::pair< Stmt, ID > freetensor::merge ( const Stmt ast,
const ID loop1,
const ID loop2 
)

◆ mergeAndHoistIf()

Stmt freetensor::mergeAndHoistIf ( const Stmt op)

◆ mergeNoDepsHint() [1/2]

std::vector< std::string > freetensor::mergeNoDepsHint ( const Stmt ast,
const ID loop1,
const ID loop2 
)
inline

◆ mergeNoDepsHint() [2/2]

std::vector< std::string > freetensor::mergeNoDepsHint ( const Stmt ast,
const std::vector< ID > &  loops 
)

When we merge or fuse some loops, we also merge the no_deps hints on them

These are 3 cases:

  1. If a variable is marked as no_deps on all the loops, keep it
  2. If a variable is marked as no_deps on some of the loops, and it is naturally free of dependence on the other loops, keep it
  3. If a variable is marked as no_deps on some of the loops, but there is dependence of it on another loop, drop it

◆ mergeTapeInput()

Stmt freetensor::mergeTapeInput ( const Stmt op)

A backward program may re-input the same taped variable multiple times. We need to merge these "input" VarDef nodes as one

◆ min()

template<PBSingleFuncRef T, PBSingleFuncRef U>
PBSingleFunc freetensor::min ( T &&  lhs,
U &&  rhs 
)

◆ mod()

auto freetensor::mod ( IntegralExceptBool auto  a,
IntegralExceptBool auto  b 
)
inline

◆ MOVE_ISL_PTR()

template<class T >
T * freetensor::MOVE_ISL_PTR ( T *&  ptr)

◆ moveDimsInputToOutput()

template<PBMapRef T>
PBMap freetensor::moveDimsInputToOutput ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsInputToParam()

template<PBMapRef T>
PBMap freetensor::moveDimsInputToParam ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

Move other dimensions to be parameters.

NOTE: This function can only be applied on named dimensions, which typically mean dimensions previously converted from parameters. For unnamed dimensions, currently you need to apply a moving mapping by yourself.

◆ moveDimsOutputToInput()

template<PBMapRef T>
PBMap freetensor::moveDimsOutputToInput ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsOutputToParam()

template<PBMapRef T>
PBMap freetensor::moveDimsOutputToParam ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsParamToInput()

template<PBMapRef T>
PBMap freetensor::moveDimsParamToInput ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsParamToOutput()

template<PBMapRef T>
PBMap freetensor::moveDimsParamToOutput ( T &&  map,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsParamToSet()

template<PBSetRef T>
PBSet freetensor::moveDimsParamToSet ( T &&  set,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveDimsSetToParam()

template<PBSetRef T>
PBSet freetensor::moveDimsSetToParam ( T &&  set,
unsigned  first,
unsigned  n,
unsigned  target 
)

◆ moveOutFirstOrLastIter()

Stmt freetensor::moveOutFirstOrLastIter ( const Stmt op)
inline

Transform loop with special case for the first or the last iteration into a loop without these cases

E.g.

Transform

for i = 0 to n if i == 0 A B

to be

A for i = 0 to n B

◆ mul() [1/3]

template<class T >
LinearExpr< T > freetensor::mul ( const LinearExpr< T > &  lin,
const T &  k 
)

◆ mul() [2/3]

LowerBound freetensor::mul ( const LowerBound b,
int  k 
)

◆ mul() [3/3]

UpperBound freetensor::mul ( const UpperBound b,
int  k 
)

◆ neg() [1/2]

template<PBMapRef T>
PBMap freetensor::neg ( T &&  map)

◆ neg() [2/2]

template<PBSetRef T>
PBSet freetensor::neg ( T &&  set)

◆ neutralVal()

Expr freetensor::neutralVal ( DataType  dtype,
ReduceOp  op 
)

◆ newArray()

Ref< Array > freetensor::newArray ( const std::vector< size_t > &  shape_,
const std::string &  dtype_,
const std::string &  data_ 
)

The function is only for serialization The original Array constructor is disabled See include/driver/array.h for more info

◆ newDomainOnlyMap()

template<PBSetRef T>
PBMap freetensor::newDomainOnlyMap ( T &&  set)

◆ newRangeOnlyMap()

template<PBSetRef T>
PBMap freetensor::newRangeOnlyMap ( T &&  set)

◆ normalizeConditionalExpr()

std::vector< std::pair< Expr, Expr > > freetensor::normalizeConditionalExpr ( const Expr expr)

Break a expression into several conditional parts.

This function is used for analyzing expressions with IfExpr inside. The result will be several parts with conditions, where each part is no longer with IfExpr.

Parameters
expr: The expression to be analyzed.
Returns
: A vector of pairs, where the first element is the value of the expression, and the second element is the condition of the expression. The condition may be null, which means the expression is always true.

◆ normalizeConditionalExprList()

std::vector< std::pair< std::vector< Expr >, Expr > > freetensor::normalizeConditionalExprList ( const std::vector< Expr > &  exprs)

Break a list of expressions into several conditional parts.

This function is used for analyzing expressions with IfExpr inside. The result will be several parts with conditions, where each part is no longer with IfExpr.

Parameters
exprs: The list of expressions to be analyzed.
Returns
: A vector of pairs, where the first element is the value of the expression list, and the second element is the condition of the expression. The condition may be null, which means the expression is always true.

◆ normalizeLoops()

Stmt freetensor::normalizeLoops ( const Stmt op,
const std::function< bool(const For &)> &  filter = nullptr 
)

Make loops to begin at 0 and have step 1

Parameters
filter: Optional. Normalize only filtered loops

◆ notLexLessAfterPermu()

std::vector< FindDepsDir > freetensor::notLexLessAfterPermu ( const std::vector< For > &  outers,
const std::vector< ID > &  permu 
)

◆ operator<<() [1/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
AccessType  atype 
)
inline

◆ operator<<() [2/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
AsMatMulMode  mode 
)
inline

◆ operator<<() [3/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
ASTNodeType  type 
)

◆ operator<<() [4/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
BaseDataType  dtype 
)
inline

◆ operator<<() [5/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const AST op 
)

Print an AST

OSTREAM_NO_PRETTY can be set via manipNoPrettyAST to enable or disable pretty print for a specific stream

◆ operator<<() [6/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const CUDAScope parallel 
)
inline

◆ operator<<() [7/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const CUDAStreamScope parallel 
)
inline

◆ operator<<() [8/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const DataType dtype 
)
inline

◆ operator<<() [9/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const Dependence dep 
)

◆ operator<<() [10/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const DiscreteObservation obs 
)

◆ operator<<() [11/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const DiscreteRandVar var 
)

◆ operator<<() [12/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const FrontendVar var 
)
inline

◆ operator<<() [13/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const FrontendVarIdx idx 
)
inline

◆ operator<<() [14/38]

template<typename Func >
auto freetensor::operator<< ( std::ostream &  os,
const Func func 
) -> decltype(func(os))

Tell std::ostream not only to treat the 3 function types in the standard as manipulators, but also arbitrary invocable types

◆ operator<<() [15/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const FuncParam p 
)

◆ operator<<() [16/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const FuncRet r 
)

◆ operator<<() [17/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const ID id 
)

◆ operator<<() [18/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const IDMetadataPack pack 
)
inline

◆ operator<<() [19/38]

template<class T >
std::ostream & freetensor::operator<< ( std::ostream &  os,
const LinearExpr< T > &  lin 
)

◆ operator<<() [20/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const Metadata md 
)

◆ operator<<() [21/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const NativeCodeParam p 
)

◆ operator<<() [22/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const NativeCodeRet r 
)

◆ operator<<() [23/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const OpenMPScope parallel 
)
inline

◆ operator<<() [24/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const ParallelScope parallel 
)
inline

◆ operator<<() [25/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const PBBuildExpr e 
)

◆ operator<<() [26/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const Ref< MetadataContent > &  mdc 
)

◆ operator<<() [27/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const Ref< Target > &  target 
)
inline

◆ operator<<() [28/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const ScheduleLogItem log 
)
inline

◆ operator<<() [29/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const SimplePBFuncAST ast 
)

◆ operator<<() [30/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
const StmtOrExprID id 
)

◆ operator<<() [31/38]

template<class T >
requires std::ranges::range<T> && (!std::convertible_to<T, std::string>)
std::ostream & freetensor::operator<< ( std::ostream &  os,
const T &  r 
)

Comma-joined print of any range

◆ operator<<() [32/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
FissionSide  side 
)
inline

◆ operator<<() [33/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
MatMulBackend  backend 
)
inline

◆ operator<<() [34/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
MemType  mtype 
)
inline

◆ operator<<() [35/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
ReorderMode  mode 
)
inline

◆ operator<<() [36/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
ScheduleType  type 
)
inline

◆ operator<<() [37/38]

std::ostream & freetensor::operator<< ( std::ostream &  os,
SignDataType  dtype 
)
inline

◆ operator<<() [38/38]

template<typename... Ts>
std::ostream & freetensor::operator<< ( std::ostream &  os,
std::tuple< Ts... > const &  tuple 
)

Comma-joined print of any tuple

◆ operator==() [1/14]

template<class T >
bool freetensor::operator== ( const Allocator< T > &  lhs,
const Allocator< T > &  rhs 
)

◆ operator==() [2/14]

template<class K , class V >
bool freetensor::operator== ( const ASTHashMap< K, V > &  lhs,
const ASTHashMap< K, V > &  rhs 
)
inline

◆ operator==() [3/14]

template<class K >
bool freetensor::operator== ( const ASTHashSet< K > &  lhs,
const ASTHashSet< K > &  rhs 
)
inline

◆ operator==() [4/14]

bool freetensor::operator== ( const CUDAScope lhs,
const CUDAScope rhs 
)
inline

◆ operator==() [5/14]

bool freetensor::operator== ( const CUDAStreamScope lhs,
const CUDAStreamScope rhs 
)
inline

◆ operator==() [6/14]

bool freetensor::operator== ( const ID lhs,
const ID rhs 
)

◆ operator==() [7/14]

template<class T >
bool freetensor::operator== ( const LinearExpr< T > &  lhs,
const LinearExpr< T > &  rhs 
)

◆ operator==() [8/14]

bool freetensor::operator== ( const OpenMPScope lhs,
const OpenMPScope rhs 
)
inline

◆ operator==() [9/14]

bool freetensor::operator== ( const PBFunc lhs,
const PBFunc rhs 
)
inline

◆ operator==() [10/14]

bool freetensor::operator== ( const PBMap lhs,
const PBMap rhs 
)
inline

◆ operator==() [11/14]

bool freetensor::operator== ( const PBSet lhs,
const PBSet rhs 
)
inline

◆ operator==() [12/14]

bool freetensor::operator== ( const PBSingleFunc lhs,
const PBSingleFunc rhs 
)
inline

◆ operator==() [13/14]

bool freetensor::operator== ( const SerialScope lhs,
const SerialScope rhs 
)
inline

◆ operator==() [14/14]

bool freetensor::operator== ( const StmtOrExprID lhs,
const StmtOrExprID rhs 
)

◆ operator|()

template<std::ranges::range Container>
auto freetensor::operator| ( Container &&  c,
const _Join joiner 
)

◆ optMul()

template<typename T >
std::optional< T > freetensor::optMul ( const std::optional< T > &  lhs,
const std::optional< T > &  rhs 
)

◆ outputAllIntermedaites()

Stmt freetensor::outputAllIntermedaites ( const Stmt op,
const std::unordered_set< ID > &  intermediates,
OutputIntermediatesStage  stage = OutputIntermediatesStage::Forward,
const std::string &  varSuffix = ".tape" 
)

A simple verison of outputIntermediates intended solely for testing. It disregards whether a variable is needed for the gradient and saves all variables specified by the user.

◆ outputIntermediates()

std::tuple< Stmt, std::unordered_map< ID, std::string >, std::unordered_map< StmtOrExprID, Expr >, std::unordered_map< ID, Expr >, std::unordered_set< ID >, std::unordered_map< std::string, std::pair< std::string, Expr > > > freetensor::outputIntermediates ( const Stmt op,
const std::unordered_map< ID, std::unordered_set< ID > > &  needVersions,
const std::unordered_map< StmtOrExprID, Derivative::LazyFullDerivative > &  derivatives,
OutputIntermediatesStage  stage = OutputIntermediatesStage::Forward,
const std::string &  varSuffix = ".tape" 
)

Save all needed versions of some specified intermediate (AccessType::Cache) variables in a program in larger tensors.

Old intermediate variables are still preserved, but may be removed using lowering passes or a inline schedule. Rationale: one intermediate (old) element maps to multiple output (new) elements, so it is hard to determine which element to load from, if directly loading from the output variable

We save the variables both after where it is stored, AND before where it is loaded.

Saving before loading is necessary because there might be random accesses, e.g.,

a[x] = 1
... = a[x]
a[y] = 2
... = a[z] # z == x or z == y

will be transformed to

a[x] = 1
a.tape[0, x] = a[x]
a.tape[0, x] = a[x]
... = a[x]
a[y] = 2
a.tape[1, y] = a[y]
a.tape[1, z] = a[z]
... = a[z]

so that even z != y, we can get the correct Version 1 a[z] in a.tape[1, z].

Saving after storing is also necessary because the gradient of y = f(x) may better be a function of y, instead of a function of x.

@params op : The program

Parameters
needVersions: {VarDef ID -> ID of Statements to analyze}
derivatives: Lazy derivative generators for each statement. We need this information to determine which values are to be used in gradients @params stage : If transforming the forward pass to save all versions of the intermediates as AccessType::Output variables (i.e. tapes), set this to Forward. If transforming the backward pass to save all versions of the intermediates but still keeping them as AccessType::Cache variables, set this to Backward @params varSuffix : Name suffix to append to the new versioning tensors
Returns
: ( The transformed program, Mapping from VarDef IDs of intermediate variables to the name of the new saving tensors, Versions of each memory accesses, Total version counts of each VarDef nodes, Set of all newly inserted statements, Mapping from tape_name to var name and explicit user versions marked via mark_version )

◆ padToSameDims()

template<PBSetRef T, PBSetRef U>
std::pair< PBSet, PBSet > freetensor::padToSameDims ( T &&  lhs,
U &&  rhs 
)

◆ parallelize()

Stmt freetensor::parallelize ( const Stmt ast,
const ID loop,
const ParallelScope parallel,
bool  allowReduction 
)

◆ parallelizeAs()

Stmt freetensor::parallelizeAs ( const Stmt ast,
const ID nest,
const ID reference,
const ID defId 
)

◆ params()

template<PBSetRef T>
PBSet freetensor::params ( T &&  set)

◆ parseAType()

AccessType freetensor::parseAType ( const std::string &  _str)
inline

◆ parseBaseDataType()

BaseDataType freetensor::parseBaseDataType ( const std::string &  _str)
inline

◆ parseDType()

DataType freetensor::parseDType ( const std::string &  str)
inline

◆ parseMatMulBackend()

MatMulBackend freetensor::parseMatMulBackend ( const std::string &  _str)
inline

◆ parseMType()

MemType freetensor::parseMType ( const std::string &  _str)
inline

◆ parseParallelScope()

ParallelScope freetensor::parseParallelScope ( const std::string &  _str)
inline

◆ parsePBFunc() [1/2]

PBFuncAST freetensor::parsePBFunc ( const PBFunc::Serialized f)

Parse a PBFunc to be ASTs

◆ parsePBFunc() [2/2]

PBFuncAST freetensor::parsePBFunc ( const PBSingleFunc::Serialized f)

◆ parsePBFuncReconstructMinMax() [1/2]

PBFuncAST freetensor::parsePBFuncReconstructMinMax ( const PBMap map)

◆ parsePBFuncReconstructMinMax() [2/2]

PBFuncAST freetensor::parsePBFuncReconstructMinMax ( const PBSet set)

Construct AST from PBSet while preserving min and max with a special hack to ISL

◆ parseSelector()

Ref< Selector > freetensor::parseSelector ( const std::string &  str)

◆ parseSignDataType()

SignDataType freetensor::parseSignDataType ( const std::string &  str)
inline

◆ parseSimplePBFunc()

SimplePBFuncAST freetensor::parseSimplePBFunc ( const auto &  f)
inline

Parse a PBFunc to be ASTs, but only restricted to one contiguous factor

◆ parseSimplePBFuncReconstructMinMax()

SimplePBFuncAST freetensor::parseSimplePBFuncReconstructMinMax ( const auto &  f)
inline

◆ pbFuncWithTimeout()

auto freetensor::pbFuncWithTimeout ( const auto &  func,
int  seconds,
const auto &...  args 
) -> std::optional<decltype(func(args...))>

◆ PBRefTake() [1/2]

template<typename T >
auto freetensor::PBRefTake ( std::remove_reference_t< T > &&  t)

◆ PBRefTake() [2/2]

template<typename T >
auto freetensor::PBRefTake ( std::remove_reference_t< T > &  t)

◆ pbSimplify()

Stmt freetensor::pbSimplify ( const Stmt op)

◆ permute()

std::pair< Stmt, std::vector< ID > > freetensor::permute ( const Stmt ast,
const std::vector< ID > &  loopsId,
const std::function< std::vector< Expr >(std::vector< Expr >)> &  transformFunc 
)

FIXME: if step != 1 or -1, this check will be more strict than actually needed; need to add range restrictions to input dimensions

TODO: more diagnostics

FIXME: if step != 1 or -1, this check will be more strict than actually needed; need to add range restrictions to input dimensions

TODO: more diagnostics

◆ plutoFuse()

std::pair< Stmt, std::pair< ID, int > > freetensor::plutoFuse ( const Stmt ast,
const ID loop0,
const ID loop1,
int  nestLevel0,
int  nestLevel1,
int  fusableOverlapThreshold,
int  fusableNonOverlapTolerance,
bool  doSimplify = true 
)

◆ plutoPermute()

std::pair< Stmt, std::pair< ID, int > > freetensor::plutoPermute ( const Stmt ast,
const ID loop,
int  nestLevel,
bool  doSimplify = true 
)

◆ projectOutAllParams() [1/2]

template<PBMapRef T>
PBMap freetensor::projectOutAllParams ( T &&  map)

◆ projectOutAllParams() [2/2]

template<PBSetRef T>
PBSet freetensor::projectOutAllParams ( T &&  set)

◆ projectOutDims()

template<PBSetRef T>
PBSet freetensor::projectOutDims ( T &&  set,
unsigned  first,
unsigned  n 
)

◆ projectOutInputDims()

template<PBMapRef T>
PBMap freetensor::projectOutInputDims ( T &&  map,
unsigned  first,
unsigned  n 
)

◆ projectOutOutputDims()

template<PBMapRef T>
PBMap freetensor::projectOutOutputDims ( T &&  map,
unsigned  first,
unsigned  n 
)

◆ projectOutParamById() [1/2]

template<PBMapRef T>
PBMap freetensor::projectOutParamById ( T &&  map,
const std::string &  name 
)

◆ projectOutParamById() [2/2]

template<PBSetRef T>
PBSet freetensor::projectOutParamById ( T &&  set,
const std::string &  name 
)

◆ projectOutParamDims() [1/2]

template<PBMapRef T>
PBMap freetensor::projectOutParamDims ( T &&  map,
unsigned  first,
unsigned  n 
)

◆ projectOutParamDims() [2/2]

template<PBSetRef T>
PBSet freetensor::projectOutParamDims ( T &&  set,
unsigned  first,
unsigned  n 
)

◆ propagateDefsNeedGrad()

std::unordered_set< ID > freetensor::propagateDefsNeedGrad ( const Stmt op,
const std::unordered_set< std::string > &  _requires,
const std::unordered_set< std::string > &  provides 
)
inline

To compute the required gradient, what intermediate gradients do we need?

◆ propOneTimeUse()

Stmt freetensor::propOneTimeUse ( const Stmt op,
const ID subAST = ID() 
)

Propagate variable if it is used only once after being assigned

E.g. transform

x[0] = a
y[0] = x[0]

into

x[0] = a
y[0] = a
Parameters
subAST: If set, only propagate in this sub-tree

◆ range()

template<PBMapRef T>
PBSet freetensor::range ( T &&  map)

◆ realDiv()

double freetensor::realDiv ( double  a,
double  b 
)
inline

Enforce casting integers to floats

◆ refineSignDataType()

Stmt freetensor::refineSignDataType ( const Stmt op)

Try to set VarDef nodes to use more restricted SignDataType

This pass only impacts SignDataType and not BaseDataType. In theory, the same algorithm could be applied to BaseDataType as well. However, users tend to explicitly set BaseDataType for implicit casting. For example, y += x[i] is often done with a short x and a longer y for floating-point precision, which is actually an implicit up-cast on x. If we were to apply this pass on BaseDataType, we would cancel this cast.

Algorithm:

  1. Set all non-I/O VarDef nodes to Never type.
  2. Check for each Store or ReduceTo. Type of a VarDef node becomes the union with type of the expressions writing to it. Propagate until converged.

◆ removeCyclicAssign()

Stmt freetensor::removeCyclicAssign ( const Stmt op)

Simplify things like a = b; b = a

◆ removeDeadVar()

Stmt freetensor::removeDeadVar ( const Stmt op)

◆ removeOutputting()

AccessType freetensor::removeOutputting ( AccessType  atype)
inline

◆ removeWrites()

Stmt freetensor::removeWrites ( const Stmt op,
const ID singleDefId = {} 
)

Remove two types of redundant writes

Type 1: Transform

x[0] = 1;
x[1] = 2;

to

x[1] = 2;

Type 2: Transform

for (i = 0; i < 5; i++) {
x[i] = i;
}

to

for (i = 0; i < 5; i++) {
if (i == 4) {
x[i] = i;
}
}

◆ renameVar() [1/2]

Stmt freetensor::renameVar ( const Stmt op,
const std::string &  oldName,
const std::string &  newName 
)
inline

◆ renameVar() [2/2]

Stmt freetensor::renameVar ( const Stmt op,
const std::unordered_map< std::string, std::string > &  rename 
)
inline

Rename a variable's definition (from VarDef or For) and use sites

This function can be applied to an AST sub-tree

◆ reorder()

Stmt freetensor::reorder ( const Stmt ast,
const std::vector< ID > &  order,
ReorderMode  mode 
)

◆ reportWarning()

void freetensor::reportWarning ( const std::string &  msg)

◆ reverse()

template<PBMapRef T>
PBMap freetensor::reverse ( T &&  map)

◆ sample()

template<PBSetRef T>
PBPoint freetensor::sample ( T &&  set)

◆ scalarPropConst()

Stmt freetensor::scalarPropConst ( const Stmt op)

Propagate scalars of constant value or only depending on iteration variables. Scalars are values in tensors indexed with constants.

E.g. transform

x[0] = 1
y[0] = x[0]

into

x[0] = 1
y[0] = 1

This version of const propagation is designed for only scalars and meant to be fast. It uses traditional dataflow techniques

◆ separateTail()

Stmt freetensor::separateTail ( const Stmt ast,
bool  noDuplicateVarDefs 
)

◆ setMemType()

Stmt freetensor::setMemType ( const Stmt ast,
const ID def,
MemType  mtype,
bool  rejectIndirectAccess 
)

◆ shrinkFor() [1/2]

Stmt freetensor::shrinkFor ( const Stmt op,
const ID subAST = ID(),
bool  doSimplify = true,
bool  unordered = false 
)

Increase the begin and decrease the end index, to remove redundant iterations from For loops

Parameters
op: The AST to transform.
subAST: If specified, only transform sub-tree of the statement with the specified ID.
doSimplify: If true, run simplify before and after the tranformation. Transformations are required to ensure the effectiveness of the shrinking. Please do your own simplification if you want to set it to false.
unordered: If true, shrink the loops aggressively which does NOT preserve the iterating order. The caller should guarantee the correctness. This is effective when the pattern of redundant iterations is complex. This may also split one loop into multiple loops.

◆ shrinkFor() [2/2]

Stmt freetensor::shrinkFor ( const Stmt op,
const Stmt subAST,
bool  doSimplify = true,
bool  unordered = false 
)
inline

◆ shrinkLinearIndices() [1/2]

Stmt freetensor::shrinkLinearIndices ( const Stmt ast)

◆ shrinkLinearIndices() [2/2]

Stmt freetensor::shrinkLinearIndices ( const Stmt ast,
const ID vardef 
)

Mutator for shrinking linear indices in variables

If a variable is consistently accessed with a linear expression, e.g., a[8i

  • 2j], and 2j as a integer bound no larger than 8, e.g., 0 <= 2j < 4, then we can shrink the expression to be a[4i + 2j].

◆ shrinkSingleVar()

Stmt freetensor::shrinkSingleVar ( const Stmt op,
const ID varDefId 
)

◆ shrinkVar()

Stmt freetensor::shrinkVar ( const Stmt op)

Make the shape of a variable smaller if some elements are not used

If you don't want to shrink some variables, please set VarDefNode::pinned_. I/O variables will not be shrinked

Set the varDefId parameter to shrink only one variable

◆ sigmoid()

double freetensor::sigmoid ( double  x)
inline

◆ simplify()

Stmt freetensor::simplify ( const Stmt op)

◆ sinkVar()

Stmt freetensor::sinkVar ( const Stmt op,
const std::optional< std::unordered_set< ID > > &  toSink = std::nullopt,
const std::function< bool(const Stmt &)> &  scopeFilter = nullptr 
)

Make the scope of a local variable smaller

If you don't want a variable to be sinked, please set VarDefNode::pinned_

Parameters
toSink: If set, sink VarDef nodes in this set only
scopeFilter: If set, only sink into scopes that this filter returns true

◆ sizeOf() [1/2]

size_t freetensor::sizeOf ( BaseDataType  dtype)

◆ sizeOf() [2/2]

size_t freetensor::sizeOf ( const DataType dtype)
inline

◆ slice() [1/2]

std::string freetensor::slice ( const std::string &  s,
int  begin 
)
inline

◆ slice() [2/2]

std::string freetensor::slice ( const std::string &  s,
int  begin,
int  end 
)

Python-like slicing that supports negative indexing as reversed indexing

◆ spaceAlloc()

PBSpace freetensor::spaceAlloc ( const Ref< PBCtx > &  ctx,
unsigned  nparam,
unsigned  nIn,
unsigned  nOut 
)
inline

◆ spaceMapFromSet()

template<PBSpaceRef T>
PBSpace freetensor::spaceMapFromSet ( T &&  space)

◆ spaceSetAlloc()

PBSpace freetensor::spaceSetAlloc ( const Ref< PBCtx > &  ctx,
unsigned  nparam,
unsigned  dim 
)
inline

◆ split()

std::pair< Stmt, std::pair< ID, ID > > freetensor::split ( const Stmt ast,
const ID id,
int  factor,
int  nparts,
int  shift = 0 
)

◆ square() [1/2]

bool freetensor::square ( bool  x)
inline

◆ square() [2/2]

template<class T >
T freetensor::square ( x)

◆ stripReturns()

std::pair< Func, std::vector< std::pair< int, Ref< Buffer > > > > freetensor::stripReturns ( const Func func)

A preprocessing step between inlinedInvoke

If the callee returns some tensors, gather information of them, in an outer-to-inner order. The caller then needs to create scopes for these tensors, before finally calling inlinedInvoke inside the scopes

Parameters
func: Function to invoke
Returns
: [0] = the stripped function. [1] = a list of returns defined from outer to inner. Each item is a pair of (position of the return value, Buffer of the return value)

◆ structuralFeature()

std::unordered_map< ID, NodeFeature > freetensor::structuralFeature ( const Stmt op)
inline

◆ sub() [1/3]

template<class T >
LinearExpr< T > freetensor::sub ( const LinearExpr< T > &  lhs,
const LinearExpr< T > &  rhs 
)

◆ sub() [2/3]

LowerBound freetensor::sub ( const LowerBound b1,
const UpperBound b2 
)

◆ sub() [3/3]

UpperBound freetensor::sub ( const UpperBound b1,
const LowerBound b2 
)

◆ subtract() [1/2]

template<PBMapRef T, PBMapRef U>
PBMap freetensor::subtract ( T &&  lhs,
U &&  rhs 
)

◆ subtract() [2/2]

template<PBSetRef T, PBSetRef U>
PBSet freetensor::subtract ( T &&  lhs,
U &&  rhs 
)

◆ sum() [1/2]

template<PBMapRef T, PBMapRef U>
PBMap freetensor::sum ( T &&  lhs,
U &&  rhs 
)

◆ sum() [2/2]

template<PBSetRef T, PBSetRef U>
PBSet freetensor::sum ( T &&  lhs,
U &&  rhs 
)

◆ swap()

Stmt freetensor::swap ( const Stmt ast,
const std::vector< ID > &  order 
)

◆ syncFunc()

template<class T >
detail::TaggedSyncFunc< std::remove_reference_t< T > > freetensor::syncFunc ( T &&  f)

Wrap a function to automatically lock itself when called

◆ tensorPropConst()

Stmt freetensor::tensorPropConst ( const Stmt op,
const ID bothInSubAST = ID(),
const ID eitherInSubAST = ID() 
)

Propagate constants and iteration variables

E.g. transform

x[i] = 1
y[i] = x[i]

into

x[i] = 1
y[i] = 1

This version of const propagation is designed for both scalars and tensors. For scalars, it directly invokes scalarPropConst. For tensors, it invokes the Presburger solver

Parameters
bothInSubAST: If set, only propagate if both the source and destination are in this sub-tree
eitherInSubAST: If set, only propagate if either the source and destination is in this sub-tree

◆ timeout()

bool freetensor::timeout ( const std::function< void()> &  func,
int  seconds 
)

Run a function with timeout

If timed out, the internal state of the function is left untouched, so there will be resource leak, and it should be tolerated.

NOTE: There are other approaches without resource leak but still not preferred: fork + kill with pages copied on write, or fork + exec a stand-alone executable + kill are possible, but both come with too much overhead. Waiting a thread until timeout and left it running is a waste of CPU time.

Returns
: True if the function successfully returns. False if the time is out

◆ tolower()

std::string freetensor::tolower ( const std::string &  s)
inline

◆ toString() [1/7]

std::string freetensor::toString ( const AST op)

Print functions for debugging

◆ toString() [2/7]

std::string freetensor::toString ( const AST op,
bool  pretty 
)

◆ toString() [3/7]

std::string freetensor::toString ( const AST op,
bool  pretty,
bool  printAllId 
)

◆ toString() [4/7]

std::string freetensor::toString ( const AST op,
bool  pretty,
bool  printAllId,
bool  dtypeInLoad,
bool  hexFloat,
bool  compact,
bool  parenDespitePriority,
bool  printSourceLocation 
)

◆ toString() [5/7]

std::string freetensor::toString ( const AST op,
bool  pretty,
bool  printAllId,
bool  dtypeInLoad,
bool  hexFloat = false,
bool  compact = false,
bool  parenDespitePriority = false 
)

◆ toString() [6/7]

std::string freetensor::toString ( const Metadata md,
bool  shouldSkipLocation = false 
)

◆ toString() [7/7]

template<class T >
requires requires(const T &obj) { requires HasStreamOutput<T>; requires !std::convertible_to<T, Ref<ASTNode>>; }
std::string freetensor::toString ( const T &  obj)

◆ undoMakeReduction() [1/2]

Stmt freetensor::undoMakeReduction ( const ReduceTo op,
DataType  dtype 
)

Transform things like a += b into a = a + b

Transform a statement

◆ undoMakeReduction() [2/2]

Stmt freetensor::undoMakeReduction ( const Stmt op)
inline

Transform things like a += b into a = a + b

Transform a whole AST

◆ uni() [1/4]

template<class T , class Hash , class KeyEqual >
std::unordered_set< T, Hash, KeyEqual > freetensor::uni ( const std::unordered_set< T, Hash, KeyEqual > &  lhs,
const std::unordered_set< T, Hash, KeyEqual > &  rhs 
)

◆ uni() [2/4]

template<class T >
std::vector< T > freetensor::uni ( const std::vector< T > &  lhs,
const std::vector< T > &  rhs 
)

◆ uni() [3/4]

template<PBMapRef T, PBMapRef U>
PBMap freetensor::uni ( T &&  lhs,
U &&  rhs 
)

◆ uni() [4/4]

template<PBSetRef T, PBSetRef U>
PBSet freetensor::uni ( T &&  lhs,
U &&  rhs 
)

◆ universeMap()

template<PBSpaceRef T>
PBMap freetensor::universeMap ( T &&  space)

◆ universeSet()

template<PBSpaceRef T>
PBSet freetensor::universeSet ( T &&  space)

◆ unmangle()

std::string freetensor::unmangle ( const std::string &  name)

◆ unroll()

Stmt freetensor::unroll ( const Stmt ast,
const ID loop,
bool  immediate 
)

◆ unsyncFunc()

template<class T >
detail::TaggedUnsyncFunc< std::remove_reference_t< T > > freetensor::unsyncFunc ( T &&  f)

Make explicit that a function is not locked when called concurrently

◆ unwrap()

template<PBSetRef T>
PBMap freetensor::unwrap ( T &&  set)

◆ upCast() [1/3]

BaseDataType freetensor::upCast ( BaseDataType  lhs,
BaseDataType  rhs 
)

Union type

Obtain a new data type containing as few as possible values, where the value is of either of the input types. Please note that although union type on BaseDataType can be used to predict the resulting type of some binary operations, this is not true for all cases and does not apply to SignDataType.

◆ upCast() [2/3]

DataType freetensor::upCast ( const DataType lhs,
const DataType rhs 
)
inline

◆ upCast() [3/3]

SignDataType freetensor::upCast ( SignDataType  lhs,
SignDataType  rhs 
)

◆ upperBoundDim()

template<PBSetRef T>
PBSet freetensor::upperBoundDim ( T &&  set,
unsigned  pos,
int  x 
)

◆ upperBoundInputDim()

template<PBMapRef T>
PBMap freetensor::upperBoundInputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ upperBoundOutputDim()

template<PBMapRef T>
PBMap freetensor::upperBoundOutputDim ( T &&  map,
unsigned  pos,
int  x 
)

◆ useBuiltinDiv()

Stmt freetensor::useBuiltinDiv ( const Stmt op)

Try to replace FloorDiv and CeilDiv with RoundTowards0Div

◆ varMerge()

Stmt freetensor::varMerge ( const Stmt ast,
const ID def,
int  dim 
)

◆ varReorder()

Stmt freetensor::varReorder ( const Stmt ast,
const ID def,
const std::vector< int > &  order 
)

◆ varReorderImpl()

Stmt freetensor::varReorderImpl ( const Stmt ast,
const ID def,
const std::vector< int > &  order,
bool  forceReorderInMatMul = false 
)

◆ varSplit()

Stmt freetensor::varSplit ( const Stmt ast,
const ID def,
int  dim,
VarSplitMode  mode,
int  factor,
int  nparts 
)

◆ varSqueeze()

Stmt freetensor::varSqueeze ( const Stmt ast,
const ID def,
int  dim 
)

◆ varUnsqueeze()

Stmt freetensor::varUnsqueeze ( const Stmt ast,
const ID def,
int  dim 
)

◆ vectorize()

Stmt freetensor::vectorize ( const Stmt ast,
const ID loop 
)

◆ wrap()

template<PBMapRef T>
PBSet freetensor::wrap ( T &&  map)

◆ z3Simplify()

Stmt freetensor::z3Simplify ( const Stmt op)

Variable Documentation

◆ accessTypeNames

constexpr std::array freetensor::accessTypeNames
constexpr
Initial value:
= {
"input", "bypass", "cache", "output", "input-mutable", "inout",
}

◆ allAccessTypes

constexpr auto freetensor::allAccessTypes
constexpr
Initial value:
= detail::createAllAccessTypes(
std::make_index_sequence<(size_t)AccessType::NumTypes>{})

◆ allBaseDataTypes

constexpr auto freetensor::allBaseDataTypes
constexpr
Initial value:
= detail::createAllBaseDataTypes(
std::make_index_sequence<(size_t)BaseDataType::NumTypes>{})

◆ allMemTypes

constexpr auto freetensor::allMemTypes
constexpr
Initial value:
= detail::createAllMemTypes(
std::make_index_sequence<(size_t)MemType::NumTypes>{})

◆ allSignDataTypes

constexpr auto freetensor::allSignDataTypes
constexpr
Initial value:
= detail::createAllSignDataTypes(
std::make_index_sequence<(size_t)SignDataType::NumTypes>{})

◆ baseDataTypeNames

constexpr std::array freetensor::baseDataTypeNames
constexpr
Initial value:
= {
"void", "float16", "float32", "float64", "int32",
"int64", "bool", "custom", "never",
}

◆ blockIdxX

constexpr ParallelScope freetensor::blockIdxX = CUDAScope{CUDAScope::Block, CUDAScope::X}
constexpr

◆ blockIdxY

constexpr ParallelScope freetensor::blockIdxY = CUDAScope{CUDAScope::Block, CUDAScope::Y}
constexpr

◆ blockIdxZ

constexpr ParallelScope freetensor::blockIdxZ = CUDAScope{CUDAScope::Block, CUDAScope::Z}
constexpr

◆ COMP_ACCESS_BOUND_ALL

const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_ALL
Initial value:
=
const CompAccessBoundMode COMP_ACCESS_BOUND_WRITE
Definition: comp_access_bound.h:28
const CompAccessBoundMode COMP_ACCESS_BOUND_READ
Definition: comp_access_bound.h:27

◆ COMP_ACCESS_BOUND_READ

const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_READ = 0x1

◆ COMP_ACCESS_BOUND_WRITE

const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_WRITE = 0x2

◆ DEP_ALL

const DepType freetensor::DEP_ALL = DEP_WAW | DEP_WAR | DEP_RAW

◆ DEP_RAW

const DepType freetensor::DEP_RAW = 0x4

◆ DEP_WAR

const DepType freetensor::DEP_WAR = 0x2

◆ DEP_WAW

const DepType freetensor::DEP_WAW = 0x1

◆ lhs

auto&& freetensor::lhs

◆ matMulBackendNames

constexpr std::array freetensor::matMulBackendNames
constexpr
Initial value:
= {
"mkl", "cublas", "cutlass", "cutlass-micro-block", "cutlass-micro-thread",
}

◆ memTypeNames

constexpr std::array freetensor::memTypeNames
constexpr
Initial value:
= {
"byvalue", "cpu", "gpu/global", "gpu/shared",
"gpu/local", "gpu/warp", "cpu/heap", "gpu/global/heap",
}

◆ OSTREAM_NO_ID_SIGN

int freetensor::OSTREAM_NO_ID_SIGN = std::ostream::xalloc()

Control over whether to output a "#" sign before an ID

Get or set the option via std::ostream::iword(), or set it via outputting manipNoIdSign to the stream

Defaults to outputting with "#"

◆ OSTREAM_NO_PRETTY

int freetensor::OSTREAM_NO_PRETTY = std::ostream::xalloc()

Control over whether to allow pretty print in a stream

Get or set the option via std::ostream::iword(), or set it via outputting manipNoPrettyAST to the stream

If set, this option overrides Config::prettyPrint() and force no pretty print. Defaults to unset

◆ rhs

auto auto&& freetensor::rhs
Initial value:
{
typedef decltype(lhs + rhs) V
auto && lhs
Definition: const_fold.cc:70
auto auto && rhs
Definition: const_fold.cc:70

◆ scheduleTypeNames

constexpr std::array freetensor::scheduleTypeNames
constexpr
Initial value:
= {
"split", "reorder", "merge",
"fission", "fuse", "swap",
"blend", "cache", "cache_reduction",
"set_mem_type", "var_split", "var_merge",
"var_reorder", "var_unsqueeze", "var_squeeze",
"inline", "parallelize", "parallelize_as",
"unroll", "vectorize", "separate_tail",
"as_matmul", "permute", "pluto_fuse",
"pluto_permute",
}

◆ serialScope

constexpr ParallelScope freetensor::serialScope = SerialScope{}
constexpr

◆ signDataTypeNames

constexpr std::array freetensor::signDataTypeNames
constexpr
Initial value:
= {
"", ">0", ">=0", "<0", "<=0", "!=0", "==0", "{}",
}

◆ SMALL_ITEM_PER_BLOCK

constexpr int freetensor::SMALL_ITEM_PER_BLOCK = 16384 / SMALL_ITEM_SIZE
constexpr

◆ SMALL_ITEM_SIZE

constexpr int freetensor::SMALL_ITEM_SIZE = 64
constexpr

◆ threadIdxX

constexpr ParallelScope freetensor::threadIdxX = CUDAScope{CUDAScope::Thread, CUDAScope::X}
constexpr

◆ threadIdxY

constexpr ParallelScope freetensor::threadIdxY = CUDAScope{CUDAScope::Thread, CUDAScope::Y}
constexpr

◆ threadIdxZ

constexpr ParallelScope freetensor::threadIdxZ = CUDAScope{CUDAScope::Thread, CUDAScope::Z}
constexpr