Go to the documentation of this file. 1 #ifndef HALIDE_SCHEDULE_H
2 #define HALIDE_SCHEDULE_H
26 struct FunctionContents;
27 struct LoopLevelContents;
180 : contents(std::move(c)) {
182 LoopLevel(
const std::string &func_name,
const std::string &var_name,
183 bool is_rvar,
int stage_index,
bool locked =
false);
220 std::string
func()
const;
243 bool match(
const std::string &loop)
const;
251 return !(*
this == other);
255 void check_defined()
const;
256 void check_locked()
const;
257 void check_defined_and_locked()
const;
266 std::map<std::string, LoopAlignStrategy>
align;
279 struct ReductionVariable;
508 FusedPair(
const std::string &f1,
size_t s1,
const std::string &f2,
509 size_t s2,
const std::string &var)
535 struct FuncScheduleContents;
536 struct StageScheduleContents;
537 struct FunctionContents;
548 : contents(std::move(c)) {
561 std::map<FunctionPtr, FunctionPtr> &copied_map)
const;
599 const std::vector<Bound> &
bounds()
const;
600 std::vector<Bound> &
bounds();
606 const std::vector<Bound> &
estimates()
const;
616 const std::map<std::string, Internal::FunctionPtr> &
wrappers()
const;
617 std::map<std::string, Internal::FunctionPtr> &
wrappers();
651 : contents(std::move(c)) {
671 const std::vector<ReductionVariable> &
rvars()
const;
672 std::vector<ReductionVariable> &
rvars();
678 const std::vector<Split> &
splits()
const;
679 std::vector<Split> &
splits();
690 const std::vector<Dim> &
dims()
const;
691 std::vector<Dim> &
dims();
697 const std::vector<PrefetchDirective> &
prefetches()
const;
void set(const LoopLevel &other)
Mutate our contents to match the contents of 'other'.
void accept(IRVisitor *) const
Pass an IRVisitor through to all Exprs referenced in the Schedule.
bool match(const std::string &loop) const
const std::vector< PrefetchDirective > & prefetches() const
You may perform prefetching in some of the dimensions of a function.
@ PredicateStores
Guard the stores in the loop with an if statement that prevents evaluation beyond the original extent...
@ AlignEnd
Shift the end of the fused loops to align.
Expr & memoize_eviction_key()
This flag is set to true if the schedule is memoized and has an attached eviction key.
std::map< std::string, LoopAlignStrategy > align
Contains alignment strategies for the fused dimensions (indexed by the dimension name).
@ GuardWithIf
Guard the inner loop with an if statement that prevents evaluation beyond the original extent.
StageSchedule(IntrusivePtr< StageScheduleContents > c)
A schedule for a Function of a Halide pipeline.
@ Predicate
Guard the loads and stores in the loop with an if statement that prevents evaluation beyond the origi...
A base class for algorithms that need to recursively walk over the IR.
@ PureVar
This dim originated from a Var.
bool operator==(const LoopLevel &other) const
DimType
Each Dim below has a dim_type, which tells you what transformations are legal on it.
bool & touched()
This flag is set to true if the dims list has been manipulated by the user (or if a ScheduleHandle wa...
const LoopLevel & compute_level() const
FuncSchedule deep_copy(std::map< FunctionPtr, FunctionPtr > &copied_map) const
Return a deep copy of this FuncSchedule.
ForType
An enum describing a type of loop traversal.
static LoopLevel root()
Construct a special LoopLevel value which represents the location outside of all for loops.
ForType for_type
How are the loop values traversed (e.g.
Expr min
Declared min and extent of the loop.
bool is_unordered_parallel() const
Could multiple iterations of this loop happen at the same time, with reads and writes interleaved in ...
A bound on a loop, typically from Func::bound.
const std::vector< Split > & splits() const
The traversal of the domain of a function can have some of its dimensions split into sub-dimensions.
LoopAlignStrategy
Different ways to handle the case when the start/end of the loops of stages computed with (fused) are...
std::string var
Name of the loop variable.
DeviceAPI device_api
On what device does the body of the loop execute (e.g.
Expr alignment
The bounds allocated (not computed) must be a multiple of "alignment".
FusedPair(const std::string &f1, size_t s1, const std::string &f2, size_t s2, const std::string &var)
bool is_unordered_parallel(ForType for_type)
Check if for_type executes for loop iterations in parallel and unordered.
bool is_parallel() const
Could multiple iterations of this loop happen at the same time? Vectorized and GPULanes loop types ar...
TailStrategy
Different ways to handle a tail case in a split when the factor does not provably divide the extent.
int stage_index() const
Return the index of the function stage associated with this loop level.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
const LoopLevel & store_level() const
At what sites should we inject the allocation and the computation of this function?...
DimType dim_type
The DimType tells us what transformations are legal on this loop (see the DimType enum above).
@ Internal
Not visible externally, similar to 'static' linkage in C.
Expr modulus
If defined, the number of iterations will be a multiple of "modulus", and the first iteration will be...
const std::vector< Dim > & dims() const
The list and ordering of dimensions used to evaluate this function, after all splits have taken place...
const std::vector< FusedPair > & fused_pairs() const
List of function stages that are to be fused with this function stage from the outermost loop to a ce...
bool & memoized()
This flag is set to true if the schedule is memoized.
@ Auto
By default, LoopAlignStrategy is set to NoAlign.
static LoopLevel inlined()
Construct a special LoopLevel value that implies that a function should be inlined away.
@ ImpureRVar
The dim originated from an RVar.
void mutate(IRMutator *)
Pass an IRMutator through to all Exprs referenced in the Schedule.
bool override_atomic_associativity_test() const
Atomic updates are only allowed on associative reductions.
const std::map< std::string, Internal::FunctionPtr > & wrappers() const
Mark calls of a function by 'f' to be replaced with its identity wrapper or clone during the lowering...
Properties of one axis of the storage of a Func.
void add_wrapper(const std::string &f, const Internal::FunctionPtr &wrapper)
const std::vector< Bound > & bounds() const
You may explicitly bound some of the dimensions of a function, or constrain them to lie on multiples ...
@ PureRVar
The dim originated from an RVar.
Expr fold_factor
If the Func is explicitly folded along this axis (with Func::fold_storage) this gives the extent of t...
void accept(IRVisitor *) const
Pass an IRVisitor through to all Exprs referenced in the Schedule.
void mutate(IRMutator *)
Pass an IRMutator through to all Exprs referenced in the Schedule.
bool allow_race_conditions() const
Are race conditions permitted?
bool atomic() const
Use atomic update?
@ NoAlign
compute_with will make no attempt to align the start/end of the fused loops.
MemoryType memory_type() const
The memory type (heap/stack/shared/etc) used to back this Func.
@ Auto
For pure definitions use ShiftInwards.
const std::vector< Bound > & estimates() const
You may explicitly specify an estimate of some of the function dimensions.
This represents two stages with fused loop nests from outermost to a specific loop level.
@ ShiftInwards
Prevent evaluation beyond the original extent by shifting the tail case inwards, re-evaluating some p...
bool operator==(const FusedPair &other) const
A possibly-weak pointer to a Halide function.
std::string var
The var in the pure definition corresponding to this axis.
A base class for passes over the IR which modify it (e.g.
bool is_parallel(ForType for_type)
Returns true if for_type executes for loop iterations in parallel.
bool is_rvar() const
Did this loop originate from an RVar (in which case the bounds of the loops are algorithmically meani...
std::string to_string() const
const std::vector< ReductionVariable > & rvars() const
RVars of reduction domain associated with this schedule if there is any.
@ RoundUp
Round up the extent to be a multiple of the split factor.
A reference-counted handle to Halide's internal representation of a function.
@ AlignStart
Shift the start of the fused loops to align.
The Dim struct represents one loop in the schedule's representation of a loop nest.
A reference to a site in a Halide statement at the top of the body of a particular for loop.
FuncSchedule(IntrusivePtr< FuncScheduleContents > c)
LoopLevel()
Construct an undefined LoopLevel.
@ PredicateLoads
Guard the loads in the loop with an if statement that prevents evaluation beyond the original extent.
StageSchedule get_copy() const
Return a copy of this StageSchedule.
Expr bound
The bounds allocated (not computed).
FuseLoopLevel(const LoopLevel &level, const std::map< std::string, LoopAlignStrategy > &align)
std::string var
The loop var being bounded.
bool operator<(const FusedPair &other) const
const FuseLoopLevel & fuse_level() const
Innermost loop level of fused loop nest for this function stage.
bool operator!=(const LoopLevel &other) const
A fragment of Halide syntax.
A class that can represent Vars or RVars.
MemoryType
An enum describing different address spaces to be used with Func::store_in.
bool is_pure() const
Can this loop be evaluated in any order (including in parallel)? Equivalently, are there no data haza...
const std::vector< StorageDim > & storage_dims() const
The list and order of dimensions used to store this function.
A schedule for a single stage of a Halide pipeline.
bool & async()
Is the production of this Function done asynchronously.
DeviceAPI
An enum describing a type of device API.