|
FreeTensor
|
Namespaces | |
| namespace | cpu |
| namespace | detail |
| namespace | gpu |
Concepts | |
| concept | PBMapRef |
| concept | PBValRef |
| concept | PBSetRef |
| concept | PBSpaceRef |
| concept | PBFuncRef |
| concept | PBSingleFuncRef |
| concept | IntegralExceptBool |
| concept | HasStreamOutput |
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< Intrinsic > | allSideEffectIntrinsics (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, LoopVariUniqVarMap > | findLoopVariance (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, NodeFeature > | structuralFeature (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< ID > | allNoReuseDefs (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< ID > | propagateDefsNeedGrad (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< Buffer > | makeBuffer (T &&tensor, AccessType atype, MemType mtype) |
| Ref< Buffer > | deepCopy (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< CutlassMicroKernelProperty > | deepCopy (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 &¶ms, 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< ReductionItem > | makeReductionItem (ReduceOp op, const std::string &var, Tbegins &&begins, Tends &&ends, bool syncFlush) |
| Ref< ReductionItem > | deepCopy (const Ref< ReductionItem > &r) |
| Ref< ForProperty > | deepCopy (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 &¶ms, Treturns &&returns, Tbody &&body) |
| template<class Tbody > | |
| Func | makeFunc (const std::string &name, const std::vector< FuncParam > ¶ms, 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 > | |
| 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< PBCtx > | commonCtx (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, PBSet > | padToSameDims (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 > | |
| 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 ¶llel) |
| bool | operator== (const CUDAStreamScope &lhs, const CUDAStreamScope &rhs) |
| std::ostream & | operator<< (std::ostream &os, const CUDAStreamScope ¶llel) |
| bool | operator== (const CUDAScope &lhs, const CUDAScope &rhs) |
| std::ostream & | operator<< (std::ostream &os, const CUDAScope ¶llel) |
| std::ostream & | operator<< (std::ostream &os, const ParallelScope ¶llel) |
| 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, ID > | fuse (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, ID > | merge (const Stmt &ast, const ID &loop1, const ID &loop2) |
| Stmt | parallelize (const Stmt &ast, const ID &loop, const ParallelScope ¶llel, 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< Selector > | parseSelector (const std::string &str) |
| AST | loadAST (const std::string &txt) |
| Ref< Target > | loadTarget (const std::string &txt, const std::string &data) |
| Ref< Device > | loadDevice (const std::string &txt, const std::string &data) |
| Ref< Array > | loadArray (const std::string &txt, const std::string &data) |
| Ref< Array > | newArray (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< ASTPart > | lca (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< Tensor > | makeTensor (T &&shape, DataType dtype) |
| Ref< Tensor > | makeTensor (std::initializer_list< Expr > shape, DataType dtype) |
| Ref< Tensor > | deepCopy (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< FindDepsDir > | notLexLessAfterPermu (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< Stmt > | findAllStmt (const Stmt &ast, const ID &id) |
| std::vector< Stmt > | findAllStmt (const Stmt &ast, const std::function< bool(const Stmt &)> &filter) |
| std::vector< Stmt > | findAllStmt (const Stmt &ast, const Ref< Selector > &selector) |
| std::vector< Stmt > | findAllStmt (const Stmt &ast, const std::string &pattern) |
| template<class T > | |
| std::vector< Stmt > | findAllStmt (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) |
| typedef Ref<AbsNode> freetensor::Abs |
| typedef Ref<AddNode> freetensor::Add |
| typedef Ref<AllocNode> freetensor::Alloc |
| using freetensor::AnonymousMetadata = typedef Ref<AnonymousMetadataContent> |
| typedef Ref<AnyNode> freetensor::Any |
| typedef Ref<AnyExprNode> freetensor::AnyExpr |
| typedef Ref<AssertNode> freetensor::Assert |
| typedef Ref<AssumeNode> freetensor::Assume |
| typedef Ref<ASTNode> freetensor::AST |
| using freetensor::ASTHashMap = typedef std::unordered_map<K, V, Hasher, HashComparator> |
| using freetensor::ASTHashSet = typedef std::unordered_set<K, Hasher, HashComparator> |
| typedef Ref<BinaryExprNode> freetensor::BinaryExpr |
| typedef Ref<BoolConstNode> freetensor::BoolConst |
| typedef Ref<CastNode> freetensor::Cast |
| typedef Ref<CeilNode> freetensor::Ceil |
| typedef Ref<CeilDivNode> freetensor::CeilDiv |
| typedef int freetensor::CompAccessBoundMode |
| typedef Ref<ConstNode> freetensor::Const |
| typedef Ref<CosNode> freetensor::Cos |
| typedef int freetensor::DepType |
| typedef std::vector<std::vector<Expr> > freetensor::DNF |
| typedef Ref<EQNode> freetensor::EQ |
| typedef Ref<EvalNode> freetensor::Eval |
| typedef Ref<ExpNode> freetensor::Exp |
| typedef Ref<ExprNode> freetensor::Expr |
| typedef SyncFunc<bool(const AccessPointBase &)> freetensor::FindDepsAccFilter |
| typedef std::function<bool(const AccessPoint &)> freetensor::FindDepsAccPtFilter |
| typedef SyncFunc<void(const Dependence &)> freetensor::FindDepsCallback |
| typedef std::vector<std::pair<NodeIDOrParallelScope, DepDirection> > freetensor::FindDepsDir |
| typedef std::function<bool(const AccessPoint &later, const AccessPoint &earlier)> freetensor::FindDepsFilter |
| typedef Ref<FloatConstNode> freetensor::FloatConst |
| typedef Ref<FloorNode> freetensor::Floor |
| typedef Ref<FloorDivNode> freetensor::FloorDiv |
| typedef Ref<ForNode> freetensor::For |
| typedef Ref<FreeNode> freetensor::Free |
| typedef Ref<FuncNode> freetensor::Func |
| typedef Ref<GENode> freetensor::GE |
| typedef Ref<GTNode> freetensor::GT |
| using freetensor::IDMetadataPack = typedef std::pair<ID, Metadata> |
| typedef Ref<IfNode> freetensor::If |
| typedef Ref<IfExprNode> freetensor::IfExpr |
| typedef Ref<IntConstNode> freetensor::IntConst |
| typedef Ref<IntrinsicNode> freetensor::Intrinsic |
| typedef Ref<LAndNode> freetensor::LAnd |
| typedef Ref<LENode> freetensor::LE |
| typedef Ref<LnNode> freetensor::Ln |
| typedef Ref<LNotNode> freetensor::LNot |
| typedef Ref<LoadNode> freetensor::Load |
| typedef std::unordered_map<StmtOrExprID , std::unordered_map<ID, LoopVariability> > freetensor::LoopVariExprMap |
| typedef std::unordered_map<std::string, std::unordered_map<ID, LoopVariability> > freetensor::LoopVariTransVarMap |
| typedef std::unordered_map<ID , std::unordered_map<ID, LoopVariability> > freetensor::LoopVariUniqVarMap |
| typedef Ref<LOrNode> freetensor::LOr |
| typedef Ref<LTNode> freetensor::LT |
| typedef Ref<MarkVersionNode> freetensor::MarkVersion |
| typedef Ref<MatMulNode> freetensor::MatMul |
| typedef Ref<MaxNode> freetensor::Max |
| using freetensor::Metadata = typedef Ref<MetadataContent> |
| using freetensor::MetadataComparator = typedef PtrInvocable<std::equal_to<MetadataContent> > |
| using freetensor::MetadataHasher = typedef PtrInvocable<std::hash<MetadataContent> > |
| typedef Ref<MinNode> freetensor::Min |
| typedef Ref<ModNode> freetensor::Mod |
| typedef Ref<MulNode> freetensor::Mul |
| typedef Ref<NENode> freetensor::NE |
| typedef std::variant<SerialScope, OpenMPScope, CUDAStreamScope, CUDAScope> freetensor::ParallelScope |
| typedef std::vector<SimplePBFuncAST> freetensor::PBFuncAST |
A PBFunc parsed as ASTs
| typedef const ProgramPositionHelper* freetensor::ProgramPosition |
| typedef std::vector<DiscreteObservation> freetensor::RandTrace |
| typedef Ref<RealDivNode> freetensor::RealDiv |
| typedef Ref<ReduceToNode> freetensor::ReduceTo |
| typedef Ref<RemainderNode> freetensor::Remainder |
| typedef SharedLinkedList<Ref<ScheduleLogItem>, ScheduleLogItemHash, ScheduleLogItemEqual> freetensor::ScheduleLog |
| typedef Ref<SigmoidNode> freetensor::Sigmoid |
| typedef Ref<SinNode> freetensor::Sin |
| using freetensor::SourceMetadata = typedef Ref<SourceMetadataContent> |
| typedef Ref<SqrtNode> freetensor::Sqrt |
| typedef Ref<SquareNode> freetensor::Square |
| typedef Ref< StmtNode > freetensor::Stmt |
| typedef Ref<StmtSeqNode> freetensor::StmtSeq |
| typedef Ref<StoreNode> freetensor::Store |
| typedef Ref<SubNode> freetensor::Sub |
| typedef Ref<TanNode> freetensor::Tan |
| typedef Ref<TanhNode> freetensor::Tanh |
| using freetensor::TransformedMetadata = typedef Ref<TransformedMetadataContent> |
| typedef Ref<UnaryExprNode> freetensor::UnaryExpr |
| typedef Ref<UnboundNode> freetensor::Unbound |
| typedef Ref<VarNode> freetensor::Var |
| typedef Ref<VarDefNode> freetensor::VarDef |
|
strong |
AccessType describes whether a tensor can be read or written
An AccessType is decided by the following properties:
Types for each combinations of the properties are:
(*) 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 | |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
| enum freetensor::NullPolicy : int |
|
strong |
|
strong |
Operation of a ReduceTo node
All operations should obey the following laws, where ?= is any of the reduction operations:
a ?= b; a ?= c equals to a ?= c; a ?= b.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 | |
|
strong |
|
strong |
|
strong |
|
strong |
| enum freetensor::VarSplitMode : int |
| T * freetensor::_COPY_ISL_PTR | ( | const T * | ptr, |
| T * | copy)(T * | ||
| ) |
| LinearExpr< T > freetensor::add | ( | const LinearExpr< T > & | lhs, |
| const LinearExpr< T > & | rhs | ||
| ) |
| LowerBound freetensor::add | ( | const LowerBound & | b1, |
| const LowerBound & | b2 | ||
| ) |
| UpperBound freetensor::add | ( | const UpperBound & | b1, |
| const UpperBound & | b2 | ||
| ) |
|
inline |
|
inline |
Collect IDs of all VarDef nodes of specific AccessTypes
|
inline |
Find names of all iterators of For nodes that are used
|
inline |
|
inline |
Find names of all VarDef nodes that are read or written, and all iterators of For nodes that are used
|
inline |
| std::vector< ID > freetensor::allNoReuseDefs | ( | const Stmt & | op, |
| const std::unordered_set< AccessType > & | atypes | ||
| ) |
|
inline |
Find names of all VarDef nodes that are read
|
inline |
| std::unordered_set< std::string > freetensor::allReads | ( | const FrontendVarIdx & | idx | ) |
| std::unordered_set< Intrinsic > freetensor::allSideEffectIntrinsics | ( | T && | op | ) |
| 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
| 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) |
|
inline |
|
inline |
Find names of all VarDef nodes that are written
|
inline |
| bool freetensor::alwaysLE | ( | const UpperBound & | b1, |
| const LowerBound & | b2 | ||
| ) |
| bool freetensor::alwaysLT | ( | const UpperBound & | b1, |
| const LowerBound & | b2 | ||
| ) |
| 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:
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:
| 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 |
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
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:
The condition x < 4 may no longer hold for stmt 2. Therefore, we annotate the AST by transform it into
| PBSet freetensor::apply | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::applyDomain | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::applyRange | ( | T && | lhs, |
| U && | rhs | ||
| ) |
Normalize an bool expression to be a disjunctive normal form
|
inline |
| Stmt freetensor::asMatMul | ( | const Stmt & | ast, |
| const ID & | loop, | ||
| MatMulBackend | backend | ||
| ) |
| freetensor::BINARY_OP_F | ( | Min | , |
| [] (auto &&lhs, auto &&rhs) { typedef decltype(lhs+rhs) V;return std::min< V >(lhs, rhs);} | |||
| ) |
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
| std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > freetensor::cache | ( | const Stmt & | ast, |
| const ID & | stmt, | ||
| const std::string & | var, | ||
| MemType | mtype | ||
| ) |
| std::pair< Stmt, std::tuple< ID, ID, std::string, ID > > freetensor::cacheReduction | ( | const Stmt & | ast, |
| const ID & | stmt, | ||
| const std::string & | var, | ||
| MemType | mtype | ||
| ) |
| PBSet freetensor::cartesianProduct | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| std::vector< T > freetensor::cat | ( | const std::vector< T > & | lhs, |
| const std::vector< T > & | rhs | ||
| ) |
| LowerBound freetensor::ceilDiv | ( | const LowerBound & | b, |
| int | k | ||
| ) |
| UpperBound freetensor::ceilDiv | ( | const UpperBound & | b, |
| int | k | ||
| ) |
|
inline |
|
inline |
|
inline |
|
inline |
| void freetensor::checkConflictId | ( | const Stmt & | ast | ) |
| 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:
expr is not defined at s0 or s1, ors0 and s1 are different, orexpr is written between s0 and s1, orexpr is thread-local, but s0 and s1 do not share the same thread. | 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
| 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.
| std::optional< bool > freetensor::checkNotModifiedFastPreCheck | ( | const Stmt & | op, |
| const Expr & | s0Expr, | ||
| const Expr & | s1Expr, | ||
| CheckNotModifiedSide | s0Side, | ||
| const ID & | s0, | ||
| CheckNotModifiedSide | s1Side, | ||
| const ID & | s1 | ||
| ) |
| PBMap freetensor::coalesce | ( | T && | map | ) |
| PBSet freetensor::coalesce | ( | T && | set | ) |
| NativeCode freetensor::codeGen | ( | const Func & | func, |
| const Ref< Target > & | target | ||
| ) |
Generate native code
| func | : The AST to be lowered. It must includes function signature to determine parameters and return values |
| target | : The target architecture |
| NativeCode freetensor::codeGenCPU | ( | const Func & | func, |
| const Ref< Target > & | target | ||
| ) |
Generate target function code
| PBSet freetensor::coefficients | ( | T && | set, |
| int64_t | c = 0 |
||
| ) |
\in X, \Sigma c_i x_i \geq c$
| set | the input set |
| c | the RHS constant |
| 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
| 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 |
| PBMap freetensor::complement | ( | T && | map | ) |
| PBSet freetensor::complement | ( | T && | set | ) |
Calculate constant (sub)expressions
For propagating constants among statements, please refer to pass/scalar_prop_const and pass/tensor_prop_const
| void freetensor::copyInfo | ( | const FromMap & | fromInfo, |
| const typename FromMap::key_type & | from, | ||
| ToMap & | toInfo, | ||
| const typename ToMap::key_type & | to | ||
| ) |
Make all VarDef nodes in tapes having globally unique names
|
inline |
|
inline |
|
inline |
| freetensor::DEFINE_PASS_FOR_FUNC | ( | makeHeapAlloc | ) |
| freetensor::DEFINE_PASS_FOR_FUNC | ( | refineSignDataType | ) |
| std::unordered_set< T, Hash, KeyEqual > freetensor::diff | ( | const std::unordered_set< T, Hash, KeyEqual > & | lhs, |
| const std::unordered_set< T, Hash, KeyEqual > & | rhs | ||
| ) |
| PBVal freetensor::dimMaxVal | ( | T && | set, |
| int | pos | ||
| ) |
| PBVal freetensor::dimMinVal | ( | T && | set, |
| int | pos | ||
| ) |
| PBSet freetensor::domain | ( | T && | map | ) |
| 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.
| SignDataType freetensor::downCast | ( | SignDataType | lhs, |
| SignDataType | rhs | ||
| ) |
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')
|
inline |
Serialize function for storing an AST and loading it back
| PBMap freetensor::emptyMap | ( | T && | space | ) |
| PBSet freetensor::emptySet | ( | T && | space | ) |
| void freetensor::exceptSafeParallelFor | ( | T | begin, |
| T | end, | ||
| T | step, | ||
| const std::function< void(T)> & | body, | ||
| omp_sched_t | schedKind, | ||
| int | schedChunkSize = 0 |
||
| ) |
Wrapper for thread safe OpenMP parallel for
| std::vector< T > freetensor::filter | ( | const std::vector< T > & | vec, |
| const U & | callback | ||
| ) |
| std::vector< Stmt > freetensor::findAllStmt | ( | const Func & | func, |
| const T & | filter | ||
| ) |
Find all statements from an AST by ID, filter or selector
| std::vector< Stmt > freetensor::findAllStmt | ( | const Stmt & | ast, |
| const std::function< bool(const Stmt &)> & | filter | ||
| ) |
|
inline |
|
inline |
Find which which buffers is indexed by which loops
| int freetensor::findInnerMostScope | ( | const std::unordered_map< std::string, int > & | varScope, |
| const Expr & | op | ||
| ) |
| 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:
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
Find the only statement from an AST by ID, filter or selector
| UnexpectedQueryResult | if zero or more than one statements are found |
| 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 | ||
| ) |
| 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 | ||
| ) |
| PBSet freetensor::fixDim | ( | T && | set, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::fixInputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::fixOutputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBSet freetensor::flatten | ( | T && | set | ) |
| PBMap freetensor::flattenDomain | ( | T && | map | ) |
| PBSet freetensor::flattenMapToSet | ( | T && | map | ) |
| PBMap freetensor::flattenRange | ( | T && | map | ) |
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)
Simplify floating-point expressions in an AST
This pass is by-passed when Config::fastMath is unset
| LowerBound freetensor::floorDiv | ( | const LowerBound & | b, |
| int | k | ||
| ) |
| UpperBound freetensor::floorDiv | ( | const UpperBound & | b, |
| int | k | ||
| ) |
|
inline |
| std::pair< Stmt, ID > freetensor::fuse | ( | const Stmt & | ast, |
| const ID & | loop0, | ||
| const ID & | loop1, | ||
| bool | strict | ||
| ) |
| T * freetensor::GET_ISL_PTR | ( | T * | ptr | ) |
| auto freetensor::getIDFromPack | ( | const std::tuple< Args... > & | args | ) |
| auto freetensor::getMetadataFromPack | ( | const std::tuple< Args... > & | args | ) |
| std::string freetensor::getNewName | ( | const std::string & | oldName, |
| const std::unordered_set< std::string > & | used | ||
| ) |
| auto freetensor::getPackFromID | ( | auto | schedule, |
| const std::tuple< Args... > & | args | ||
| ) |
| std::optional< std::pair< ID, ID > > freetensor::getRangeFromStmtSeq | ( | const Stmt & | op, |
| const std::unordered_set< ID > & | stmts | ||
| ) |
| 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
| 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 |
| 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 = {} |
||
| ) |
| 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 = {} |
||
| ) |
| size_t freetensor::hashCombine | ( | size_t | seed, |
| size_t | other | ||
| ) |
| bool freetensor::hasIdenticalCoeff | ( | const LinearExpr< T > & | lhs, |
| const LinearExpr< T > & | rhs | ||
| ) |
| bool freetensor::hasIntersect | ( | const std::unordered_set< T, Hash, KeyEqual > & | lhs, |
| const std::unordered_set< T, Hash, KeyEqual > & | rhs | ||
| ) |
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
| selector | : Hoist all VarDef nodes in this area |
| InvalidSchedule | if the hoisting is impossible |
| 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 possbilehoistVarOverStmtSeq(op, togetherIds): Hoist some VarDefs to make all statements in togetherIds are in the same VarDefs, while leaving other VarDefs untouched | PBMap freetensor::identity | ( | T && | space | ) |
| 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
| 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 |
| PBSet freetensor::insertDims | ( | T && | set, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBMap freetensor::insertInputDims | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBMap freetensor::insertOutputDims | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| 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 | ||
| ) |
| std::unordered_set< T, Hash, KeyEqual > freetensor::intersect | ( | const std::unordered_set< T, Hash, KeyEqual > & | lhs, |
| const std::unordered_set< T, Hash, KeyEqual > & | rhs | ||
| ) |
| std::vector< T > freetensor::intersect | ( | const std::vector< T > & | lhs, |
| const std::vector< T > & | rhs | ||
| ) |
| PBMap freetensor::intersect | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSet freetensor::intersect | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::intersectDomain | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSingleFunc freetensor::intersectDomain | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBFunc freetensor::intersectDomain | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSet freetensor::intersectParams | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::intersectParams | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::intersectRange | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| 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.
| 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 |
| bool freetensor::isBool | ( | BaseDataType | dtype | ) |
|
inline |
|
inline |
| bool freetensor::isEQ0 | ( | SignDataType | dtype | ) |
| bool freetensor::isFloat | ( | BaseDataType | dtype | ) |
|
inline |
|
inline |
| bool freetensor::isGE0 | ( | SignDataType | dtype | ) |
|
inline |
| bool freetensor::isGT0 | ( | SignDataType | dtype | ) |
|
inline |
| bool freetensor::isInt | ( | BaseDataType | dtype | ) |
|
inline |
|
inline |
| bool freetensor::isLE0 | ( | SignDataType | dtype | ) |
|
inline |
| bool freetensor::isLT0 | ( | SignDataType | dtype | ) |
|
inline |
| bool freetensor::isNE0 | ( | SignDataType | dtype | ) |
|
inline |
|
inline |
|
inline |
| bool freetensor::isSubSetOf | ( | const std::unordered_set< T, Hash, KeyEqual > & | lhs, |
| const std::unordered_set< T, Hash, KeyEqual > & | rhs | ||
| ) |
| bool freetensor::isVariant | ( | const LoopVariExprMap & | exprInfo, |
| const StmtOrExprID & | expr, | ||
| const ID & | loop | ||
| ) |
| bool freetensor::isVariant | ( | const LoopVariUniqVarMap & | varInfo, |
| const ID & | defId, | ||
| const ID & | loop | ||
| ) |
| bool freetensor::isVariant | ( | const LoopVariUniqVarMap & | varInfo, |
| const VarDef & | def, | ||
| const ID & | loop | ||
| ) |
|
inline |
|
inline |
| std::string freetensor::join | ( | Container && | c, |
| const std::string & | splitter | ||
| ) |
| freetensor::Lazy | ( | F | delayedInit | ) | -> Lazy< std::decay_t< decltype(std::declval< F >()())> > |
Lowest common ancestor
| PBMap freetensor::lexGE | ( | T && | space | ) |
| PBMap freetensor::lexGT | ( | T && | space | ) |
| PBMap freetensor::lexLE | ( | T && | space | ) |
| PBMap freetensor::lexLT | ( | T && | space | ) |
| PBMap freetensor::lexmax | ( | T && | map | ) |
| PBSet freetensor::lexmax | ( | T && | set | ) |
| PBMap freetensor::lexmin | ( | T && | map | ) |
| PBSet freetensor::lexmin | ( | T && | set | ) |
| 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"
| 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
| LinearExpr< int64_t > freetensor::linear | ( | const Expr & | expr | ) |
Try to represent each (sub)expression as a linear expression of memory accesses and loop iterators
| std::optional< std::pair< LinearExpr< int64_t >, ASTNodeType > > freetensor::linearComp | ( | const Expr & | expr | ) |
Try to represent an comparison as a "LINEAR OP 0" form
| AST freetensor::loadAST | ( | const std::string & | txt | ) |
|
inline |
| 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
| 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 |
| PBSet freetensor::lowerBoundDim | ( | T && | set, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::lowerBoundInputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::lowerBoundOutputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| 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 | ||
| ) |
| Expr freetensor::makeAbs | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeAdd | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
|
inline |
|
inline |
| Stmt freetensor::makeAssert | ( | Tcond && | cond, |
| Tbody && | body, | ||
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Stmt freetensor::makeAssume | ( | Tcond && | cond, |
| Tbody && | body, | ||
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeBinary | ( | ASTNodeType | nodeType, |
| T && | lhs, | ||
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
| Ref< Buffer > freetensor::makeBuffer | ( | T && | tensor, |
| AccessType | atype, | ||
| MemType | mtype | ||
| ) |
| Expr freetensor::makeCast | ( | T && | expr, |
| DataType | destType, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeCeil | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeCeilDiv | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeCos | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeEQ | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Stmt freetensor::makeEval | ( | T && | expr, |
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeExp | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
| Expr freetensor::makeFloor | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeFloorDiv | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| 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() |
||
| ) |
|
inline |
| Func freetensor::makeFunc | ( | const std::string & | name, |
| const std::vector< FuncParam > & | params, | ||
| const std::vector< FuncRet > & | returns, | ||
| Tbody && | body | ||
| ) |
| Func freetensor::makeFunc | ( | const std::string & | name, |
| Tparams && | params, | ||
| Treturns && | returns, | ||
| Tbody && | body | ||
| ) |
| Expr freetensor::makeGE | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeGT | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
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
| Stmt freetensor::makeIf | ( | Tcond && | cond, |
| Tthen && | thenCase, | ||
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Stmt freetensor::makeIf | ( | Tcond && | cond, |
| Tthen && | thenCase, | ||
| Telse && | elseCase, | ||
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeIfExpr | ( | T && | cond, |
| U && | thenCase, | ||
| V && | elseCase, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
|
inline |
| Expr freetensor::makeIntrinsic | ( | const std::string & | format, |
| T && | params, | ||
| DataType | retType, | ||
| bool | hasSideEffect, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeLAnd | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeLE | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeLn | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeLNot | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
| Expr freetensor::makeLoad | ( | const std::string & | var, |
| Tindices && | indices, | ||
| DataType | loadType, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
|
inline |
| Expr freetensor::makeLOr | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
Make l_or(l_and(...), l_and(...), ...) and remove duplications
| 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. |
| Expr freetensor::makeLT | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
|
inline |
| Expr freetensor::makeMax | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeMaxMin | ( | const std::vector< std::vector< Expr > > & | exprs, |
| const T & | negInf, | ||
| const U & | inf | ||
| ) |
Make max(min(...), min(...), ...) and remove duplications
| 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. |
| Expr freetensor::makeMaxMinImpl | ( | const std::vector< std::vector< Expr > > & | exprs, |
| const std::function< Expr()> & | inf, | ||
| const std::function< Expr()> & | negInf | ||
| ) |
| AnonymousMetadata freetensor::makeMetadata | ( | const ID & | id = {} | ) |
| TransformedMetadata freetensor::makeMetadata | ( | const std::string & | op, |
| const std::vector< Metadata > & | sources | ||
| ) |
| 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.
| op | operation of the TransformedMetadata |
| sourceStmts | variadic parameters that accept the source Stmts. |
| SourceMetadata freetensor::makeMetadata | ( | const std::vector< std::string > & | labels, |
| const std::optional< std::pair< std::string, int > > & | location, | ||
| const Metadata & | callerMetadata | ||
| ) |
| Expr freetensor::makeMin | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeMinMax | ( | const std::vector< std::vector< Expr > > & | exprs, |
| const T & | inf, | ||
| const U & | negInf | ||
| ) |
Make min(max(...), max(...), ...) and remove duplications
| 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. |
| Expr freetensor::makeMinMaxImpl | ( | const std::vector< std::vector< Expr > > & | exprs, |
| const std::function< Expr()> & | inf, | ||
| const std::function< Expr()> & | negInf | ||
| ) |
| Expr freetensor::makeMod | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeMul | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeNE | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| 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
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.
| target | : Target information. Can be null for target-agnostic debugging |
| Expr freetensor::makeRealDiv | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| 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() |
||
| ) |
| 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() |
||
| ) |
|
inline |
Transform things like a = a + b into a += b
This is to make the dependence analysis more accurate
| types | : Only transform these types of reductions |
| canonicalOnly | : True to avoid cyclic reductions like a += a + b |
| Ref< ReductionItem > freetensor::makeReductionItem | ( | ReduceOp | op, |
| const std::string & | var, | ||
| Tbegins && | begins, | ||
| Tends && | ends, | ||
| bool | syncFlush | ||
| ) |
| Expr freetensor::makeRemainder | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeRoundTowards0Div | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeSigmoid | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeSin | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeSqrt | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeSquare | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
| Stmt freetensor::makeStmtSeq | ( | Tstmts && | stmts, |
| const Metadata & | metadata = nullptr, |
||
| const ID & | id = {}, |
||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| 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() |
||
| ) |
| 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() |
||
| ) |
| Expr freetensor::makeSub | ( | T && | lhs, |
| U && | rhs, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeTan | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeTanh | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeUnary | ( | ASTNodeType | nodeType, |
| T && | expr, | ||
| std::source_location | loc = std::source_location::current() |
||
| ) |
| Expr freetensor::makeUnbound | ( | T && | expr, |
| std::source_location | loc = std::source_location::current() |
||
| ) |
|
inline |
| 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() |
||
| ) |
| std::string freetensor::mangle | ( | const std::string & | name | ) |
| std::ostream & freetensor::manipMetadataMultiLine | ( | std::ostream & | os | ) |
| std::ostream & freetensor::manipMetadataNoId | ( | std::ostream & | os | ) |
| std::ostream & freetensor::manipMetadataOneLine | ( | std::ostream & | os | ) |
| std::ostream & freetensor::manipMetadataPrintId | ( | std::ostream & | os | ) |
| std::ostream & freetensor::manipMetadataSkipLocation | ( | std::ostream & | os | ) |
| std::ostream & freetensor::manipMetadataWithLocation | ( | std::ostream & | os | ) |
| std::function< std::ostream &(std::ostream &)> freetensor::manipNoIdSign | ( | bool | flag | ) |
| std::function< std::ostream &(std::ostream &)> freetensor::manipNoPrettyAST | ( | bool | flag | ) |
| PBSingleFunc freetensor::max | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| void freetensor::meetTo | ( | const FromMap & | fromInfo, |
| const typename FromMap::key_type & | from, | ||
| ToMap & | toInfo, | ||
| const typename ToMap::key_type & | to | ||
| ) |
|
inline |
| 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:
A backward program may re-input the same taped variable multiple times. We need to merge these "input" VarDef nodes as one
| PBSingleFunc freetensor::min | ( | T && | lhs, |
| U && | rhs | ||
| ) |
|
inline |
| T * freetensor::MOVE_ISL_PTR | ( | T *& | ptr | ) |
| PBMap freetensor::moveDimsInputToOutput | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| 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.
| PBMap freetensor::moveDimsOutputToInput | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| PBMap freetensor::moveDimsOutputToParam | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| PBMap freetensor::moveDimsParamToInput | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| PBMap freetensor::moveDimsParamToOutput | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| PBSet freetensor::moveDimsParamToSet | ( | T && | set, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
| PBSet freetensor::moveDimsSetToParam | ( | T && | set, |
| unsigned | first, | ||
| unsigned | n, | ||
| unsigned | target | ||
| ) |
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
| LinearExpr< T > freetensor::mul | ( | const LinearExpr< T > & | lin, |
| const T & | k | ||
| ) |
| LowerBound freetensor::mul | ( | const LowerBound & | b, |
| int | k | ||
| ) |
| UpperBound freetensor::mul | ( | const UpperBound & | b, |
| int | k | ||
| ) |
| PBMap freetensor::neg | ( | T && | map | ) |
| PBSet freetensor::neg | ( | T && | set | ) |
| 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
| PBMap freetensor::newDomainOnlyMap | ( | T && | set | ) |
| PBMap freetensor::newRangeOnlyMap | ( | T && | set | ) |
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.
| expr | : The expression to be analyzed. |
| 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.
| exprs | : The list of expressions to be analyzed. |
| Stmt freetensor::normalizeLoops | ( | const Stmt & | op, |
| const std::function< bool(const For &)> & | filter = nullptr |
||
| ) |
Make loops to begin at 0 and have step 1
| filter | : Optional. Normalize only filtered loops |
| std::vector< FindDepsDir > freetensor::notLexLessAfterPermu | ( | const std::vector< For > & | outers, |
| const std::vector< ID > & | permu | ||
| ) |
|
inline |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| ASTNodeType | type | ||
| ) |
|
inline |
| 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
|
inline |
|
inline |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const Dependence & | dep | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const DiscreteObservation & | obs | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const DiscreteRandVar & | var | ||
| ) |
|
inline |
|
inline |
| 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
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const FuncParam & | p | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const FuncRet & | r | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const ID & | id | ||
| ) |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const LinearExpr< T > & | lin | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const Metadata & | md | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const NativeCodeParam & | p | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const NativeCodeRet & | r | ||
| ) |
|
inline |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const PBBuildExpr & | e | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const Ref< MetadataContent > & | mdc | ||
| ) |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const SimplePBFuncAST & | ast | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const StmtOrExprID & | id | ||
| ) |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| const T & | r | ||
| ) |
Comma-joined print of any range
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| std::ostream & freetensor::operator<< | ( | std::ostream & | os, |
| std::tuple< Ts... > const & | tuple | ||
| ) |
Comma-joined print of any tuple
| bool freetensor::operator== | ( | const Allocator< T > & | lhs, |
| const Allocator< T > & | rhs | ||
| ) |
|
inline |
|
inline |
|
inline |
| bool freetensor::operator== | ( | const LinearExpr< T > & | lhs, |
| const LinearExpr< T > & | rhs | ||
| ) |
|
inline |
|
inline |
|
inline |
| bool freetensor::operator== | ( | const StmtOrExprID & | lhs, |
| const StmtOrExprID & | rhs | ||
| ) |
| auto freetensor::operator| | ( | Container && | c, |
| const _Join & | joiner | ||
| ) |
| std::optional< T > freetensor::optMul | ( | const std::optional< T > & | lhs, |
| const std::optional< T > & | rhs | ||
| ) |
| 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.
| 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.,
will be transformed to
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
| 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 |
| std::pair< PBSet, PBSet > freetensor::padToSameDims | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| Stmt freetensor::parallelize | ( | const Stmt & | ast, |
| const ID & | loop, | ||
| const ParallelScope & | parallel, | ||
| bool | allowReduction | ||
| ) |
| Stmt freetensor::parallelizeAs | ( | const Stmt & | ast, |
| const ID & | nest, | ||
| const ID & | reference, | ||
| const ID & | defId | ||
| ) |
| PBSet freetensor::params | ( | T && | set | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| PBFuncAST freetensor::parsePBFunc | ( | const PBFunc::Serialized & | f | ) |
Parse a PBFunc to be ASTs
| PBFuncAST freetensor::parsePBFunc | ( | const PBSingleFunc::Serialized & | f | ) |
Construct AST from PBSet while preserving min and max with a special hack to ISL
|
inline |
|
inline |
Parse a PBFunc to be ASTs, but only restricted to one contiguous factor
|
inline |
| auto freetensor::pbFuncWithTimeout | ( | const auto & | func, |
| int | seconds, | ||
| const auto &... | args | ||
| ) | -> std::optional<decltype(func(args...))> |
| auto freetensor::PBRefTake | ( | std::remove_reference_t< T > && | t | ) |
| auto freetensor::PBRefTake | ( | std::remove_reference_t< T > & | t | ) |
| 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
| 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 |
||
| ) |
| std::pair< Stmt, std::pair< ID, int > > freetensor::plutoPermute | ( | const Stmt & | ast, |
| const ID & | loop, | ||
| int | nestLevel, | ||
| bool | doSimplify = true |
||
| ) |
| PBMap freetensor::projectOutAllParams | ( | T && | map | ) |
| PBSet freetensor::projectOutAllParams | ( | T && | set | ) |
| PBSet freetensor::projectOutDims | ( | T && | set, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBMap freetensor::projectOutInputDims | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBMap freetensor::projectOutOutputDims | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBMap freetensor::projectOutParamById | ( | T && | map, |
| const std::string & | name | ||
| ) |
| PBSet freetensor::projectOutParamById | ( | T && | set, |
| const std::string & | name | ||
| ) |
| PBMap freetensor::projectOutParamDims | ( | T && | map, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
| PBSet freetensor::projectOutParamDims | ( | T && | set, |
| unsigned | first, | ||
| unsigned | n | ||
| ) |
|
inline |
To compute the required gradient, what intermediate gradients do we need?
Propagate variable if it is used only once after being assigned
E.g. transform
into
| subAST | : If set, only propagate in this sub-tree |
| PBSet freetensor::range | ( | T && | map | ) |
|
inline |
Enforce casting integers to floats
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:
|
inline |
Remove two types of redundant writes
Type 1: Transform
to
Type 2: Transform
to
|
inline |
|
inline |
Rename a variable's definition (from VarDef or For) and use sites
This function can be applied to an AST sub-tree
| Stmt freetensor::reorder | ( | const Stmt & | ast, |
| const std::vector< ID > & | order, | ||
| ReorderMode | mode | ||
| ) |
| void freetensor::reportWarning | ( | const std::string & | msg | ) |
| PBMap freetensor::reverse | ( | T && | map | ) |
| PBPoint freetensor::sample | ( | T && | set | ) |
Propagate scalars of constant value or only depending on iteration variables. Scalars are values in tensors indexed with constants.
E.g. transform
into
This version of const propagation is designed for only scalars and meant to be fast. It uses traditional dataflow techniques
| Stmt freetensor::setMemType | ( | const Stmt & | ast, |
| const ID & | def, | ||
| MemType | mtype, | ||
| bool | rejectIndirectAccess | ||
| ) |
| 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
| 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. |
|
inline |
Mutator for shrinking linear indices in variables
If a variable is consistently accessed with a linear expression, e.g., a[8i
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]. 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
|
inline |
| 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_
| toSink | : If set, sink VarDef nodes in this set only |
| scopeFilter | : If set, only sink into scopes that this filter returns true |
| size_t freetensor::sizeOf | ( | BaseDataType | dtype | ) |
|
inline |
|
inline |
| std::string freetensor::slice | ( | const std::string & | s, |
| int | begin, | ||
| int | end | ||
| ) |
Python-like slicing that supports negative indexing as reversed indexing
|
inline |
| PBSpace freetensor::spaceMapFromSet | ( | T && | space | ) |
|
inline |
| std::pair< Stmt, std::pair< ID, ID > > freetensor::split | ( | const Stmt & | ast, |
| const ID & | id, | ||
| int | factor, | ||
| int | nparts, | ||
| int | shift = 0 |
||
| ) |
|
inline |
| T freetensor::square | ( | T | x | ) |
| 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
| func | : Function to invoke |
|
inline |
| LinearExpr< T > freetensor::sub | ( | const LinearExpr< T > & | lhs, |
| const LinearExpr< T > & | rhs | ||
| ) |
| LowerBound freetensor::sub | ( | const LowerBound & | b1, |
| const UpperBound & | b2 | ||
| ) |
| UpperBound freetensor::sub | ( | const UpperBound & | b1, |
| const LowerBound & | b2 | ||
| ) |
| PBMap freetensor::subtract | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSet freetensor::subtract | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::sum | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSet freetensor::sum | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| detail::TaggedSyncFunc< std::remove_reference_t< T > > freetensor::syncFunc | ( | T && | f | ) |
Wrap a function to automatically lock itself when called
| Stmt freetensor::tensorPropConst | ( | const Stmt & | op, |
| const ID & | bothInSubAST = ID(), |
||
| const ID & | eitherInSubAST = ID() |
||
| ) |
Propagate constants and iteration variables
E.g. transform
into
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
| 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 |
| 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.
|
inline |
| std::string freetensor::toString | ( | const AST & | op | ) |
Print functions for debugging
| std::string freetensor::toString | ( | const AST & | op, |
| bool | pretty | ||
| ) |
| std::string freetensor::toString | ( | const AST & | op, |
| bool | pretty, | ||
| bool | printAllId | ||
| ) |
| std::string freetensor::toString | ( | const AST & | op, |
| bool | pretty, | ||
| bool | printAllId, | ||
| bool | dtypeInLoad, | ||
| bool | hexFloat, | ||
| bool | compact, | ||
| bool | parenDespitePriority, | ||
| bool | printSourceLocation | ||
| ) |
| std::string freetensor::toString | ( | const AST & | op, |
| bool | pretty, | ||
| bool | printAllId, | ||
| bool | dtypeInLoad, | ||
| bool | hexFloat = false, |
||
| bool | compact = false, |
||
| bool | parenDespitePriority = false |
||
| ) |
| std::string freetensor::toString | ( | const Metadata & | md, |
| bool | shouldSkipLocation = false |
||
| ) |
| std::string freetensor::toString | ( | const T & | obj | ) |
Transform things like a += b into a = a + b
Transform a statement
Transform things like a += b into a = a + b
Transform a whole AST
| std::unordered_set< T, Hash, KeyEqual > freetensor::uni | ( | const std::unordered_set< T, Hash, KeyEqual > & | lhs, |
| const std::unordered_set< T, Hash, KeyEqual > & | rhs | ||
| ) |
| std::vector< T > freetensor::uni | ( | const std::vector< T > & | lhs, |
| const std::vector< T > & | rhs | ||
| ) |
| PBMap freetensor::uni | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBSet freetensor::uni | ( | T && | lhs, |
| U && | rhs | ||
| ) |
| PBMap freetensor::universeMap | ( | T && | space | ) |
| PBSet freetensor::universeSet | ( | T && | space | ) |
| std::string freetensor::unmangle | ( | const std::string & | name | ) |
| detail::TaggedUnsyncFunc< std::remove_reference_t< T > > freetensor::unsyncFunc | ( | T && | f | ) |
Make explicit that a function is not locked when called concurrently
| PBMap freetensor::unwrap | ( | T && | set | ) |
| 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.
| SignDataType freetensor::upCast | ( | SignDataType | lhs, |
| SignDataType | rhs | ||
| ) |
| PBSet freetensor::upperBoundDim | ( | T && | set, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::upperBoundInputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
| PBMap freetensor::upperBoundOutputDim | ( | T && | map, |
| unsigned | pos, | ||
| int | x | ||
| ) |
Try to replace FloorDiv and CeilDiv with RoundTowards0Div
| Stmt freetensor::varReorderImpl | ( | const Stmt & | ast, |
| const ID & | def, | ||
| const std::vector< int > & | order, | ||
| bool | forceReorderInMatMul = false |
||
| ) |
| Stmt freetensor::varSplit | ( | const Stmt & | ast, |
| const ID & | def, | ||
| int | dim, | ||
| VarSplitMode | mode, | ||
| int | factor, | ||
| int | nparts | ||
| ) |
| PBSet freetensor::wrap | ( | T && | map | ) |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
| const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_ALL |
| const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_READ = 0x1 |
| const CompAccessBoundMode freetensor::COMP_ACCESS_BOUND_WRITE = 0x2 |
| const DepType freetensor::DEP_RAW = 0x4 |
| const DepType freetensor::DEP_WAR = 0x2 |
| const DepType freetensor::DEP_WAW = 0x1 |
| auto&& freetensor::lhs |
|
constexpr |
|
constexpr |
| 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 "#"
| 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
| auto auto&& freetensor::rhs |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |