1 #ifndef HALIDE_SCHEDULE_H 2 #define HALIDE_SCHEDULE_H 27 struct FunctionContents;
28 struct LoopLevelContents;
207 : contents(std::move(c)) {
249 std::string
func()
const;
287 bool match(
const std::string &loop)
const;
295 return !(*
this == other);
299 void check_defined()
const;
300 void check_locked()
const;
301 void check_defined_and_locked()
const;
310 std::map<std::string, LoopAlignStrategy>
align;
323 struct ReductionVariable;
555 FusedPair(
const std::string &f1,
size_t s1,
const std::string &f2,
556 size_t s2,
const std::string &var)
582 struct FuncScheduleContents;
583 struct StageScheduleContents;
584 struct FunctionContents;
595 : contents(
std::move(c)) {
608 std::map<FunctionPtr, FunctionPtr> &copied_map)
const;
646 const std::vector<Bound> &
bounds()
const;
647 std::vector<Bound> &
bounds();
653 const std::vector<Bound> &
estimates()
const;
663 const std::map<std::string, Internal::FunctionPtr> &
wrappers()
const;
664 std::map<std::string, Internal::FunctionPtr> &
wrappers();
700 : contents(
std::move(c)) {
705 const std::vector<Dim> &
dims,
const std::vector<PrefetchDirective> &
prefetches,
724 const std::vector<ReductionVariable> &
rvars()
const;
725 std::vector<ReductionVariable> &
rvars();
731 const std::vector<Split> &
splits()
const;
732 std::vector<Split> &
splits();
743 const std::vector<Dim> &
dims()
const;
744 std::vector<Dim> &
dims();
750 const std::vector<PrefetchDirective> &
prefetches()
const;
bool is_unordered_parallel(ForType for_type)
Check if for_type executes for loop iterations in parallel and unordered.
A reference to a site in a Halide statement at the top of the body of a particular for loop...
A base class for algorithms that need to recursively walk over the IR.
bool & touched()
This flag is set to true if the dims list has been manipulated by the user (or if a ScheduleHandle wa...
A schedule for a single stage of a Halide pipeline.
A fragment of Halide syntax.
const LoopLevel & hoist_storage_level() const
At what sites should we inject the allocation and the computation of this function? The store_level must be outside of or equal to the compute_level.
Prevent evaluation beyond the original extent by shifting the tail case inwards, re-evaluating some p...
Defines the PrefetchDirective struct.
FusedPair(const std::string &f1, size_t s1, const std::string &f2, size_t s2, const std::string &var)
void accept(IRVisitor *) const
Pass an IRVisitor through to all Exprs referenced in the Schedule.
Partition
Different ways to handle loops with a potentially optimizable boundary conditions.
Expr fold_factor
If the Func is explicitly folded along this axis (with Func::fold_storage) this gives the extent of t...
A possibly-weak pointer to a Halide function.
TailStrategy
Different ways to handle a tail case in a split when the factor does not provably divide the extent...
bool & async()
Is the production of this Function done asynchronously.
Round up the extent to be a multiple of the split factor.
int get_stage_index() const
FuncSchedule deep_copy(std::map< FunctionPtr, FunctionPtr > &copied_map) const
Return a deep copy of this FuncSchedule.
StageSchedule(IntrusivePtr< StageScheduleContents > c)
FuseLoopLevel(const LoopLevel &level, const std::map< std::string, LoopAlignStrategy > &align)
std::string var
Name of the loop variable.
ForType for_type
How are the loop values traversed (e.g.
The dim originated from an RVar.
bool operator==(const FusedPair &other) const
bool is_unordered_parallel() const
Could multiple iterations of this loop happen at the same time, with reads and writes interleaved in ...
Expr min
Declared min and extent of the loop.
StageSchedule get_copy() const
Return a copy of this StageSchedule.
Defines the Partition enum.
DeviceAPI device_api
On what device does the body of the loop execute (e.g.
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, and contains methods to using Halide's bounds tools to query properties of it.
bool atomic() const
Use atomic update?
A class that can represent Vars or RVars.
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...
Guard the loads in the loop with an if statement that prevents evaluation beyond the original extent...
Guard the stores in the loop with an if statement that prevents evaluation beyond the original extent...
bool is_parallel() const
Could multiple iterations of this loop happen at the same time? Vectorized and GPULanes loop types ar...
DimType
Each Dim below has a dim_type, which tells you what transformations are legal on it.
bool is_parallel(ForType for_type)
Returns true if for_type executes for loop iterations in parallel.
Expr & memoize_eviction_key()
This flag is set to true if the schedule is memoized and has an attached eviction key...
const LoopLevel & compute_level() const
At what sites should we inject the allocation and the computation of this function? The store_level must be outside of or equal to the compute_level.
std::string var_name() const
bool override_atomic_associativity_test() const
Atomic updates are only allowed on associative reductions.
bool & memoized()
This flag is set to true if the schedule is memoized.
void mutate(IRMutator *)
Pass an IRMutator through to all Exprs referenced in the Schedule.
DimType dim_type
The DimType tells us what transformations are legal on this loop (see the DimType enum above)...
LoopAlignStrategy
Different ways to handle the case when the start/end of the loops of stages computed with (fused) are...
Guard the prefetch with if-guards that ignores the prefetch if any of the prefetched region ever goes...
A schedule for a Function of a Halide pipeline.
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt) ...
MemoryType memory_type() const
The memory type (heap/stack/shared/etc) used to back this Func.
static LoopLevel root()
Construct a special LoopLevel value which represents the location outside of all for loops...
void add_wrapper(const std::string &f, const Internal::FunctionPtr &wrapper)
Mark calls of a function by 'f' to be replaced with its identity wrapper or clone during the lowering...
Expr alignment
The bounds allocated (not computed) must be a multiple of "alignment".
Shift the end of the fused loops to align.
const std::vector< Bound > & bounds() const
You may explicitly bound some of the dimensions of a function, or constrain them to lie on multiples ...
Guard the loads and stores in the loop with an if statement that prevents evaluation beyond the origi...
The dim originated from an RVar.
const LoopLevel & store_level() const
At what sites should we inject the allocation and the computation of this function? The store_level must be outside of or equal to the compute_level.
Expr bound
The bounds allocated (not computed).
Expr modulus
If defined, the number of iterations will be a multiple of "modulus", and the first iteration will be...
Let Halide select a storage type automatically.
Partition partition_policy
The strategy for loop partitioning.
A bound on a loop, typically from Func::bound.
Not visible externally, similar to 'static' linkage in C.
compute_with will make no attempt to align the start/end of the fused loops.
bool is_rvar() const
Did this loop originate from an RVar (in which case the bounds of the loops are algorithmically meani...
const std::vector< Bound > & estimates() const
You may explicitly specify an estimate of some of the function dimensions.
std::map< std::string, LoopAlignStrategy > align
Contains alignment strategies for the fused dimensions (indexed by the dimension name).
Defines the internal representation of parameters to halide piplines.
Shift the start of the fused loops to align.
ForType
An enum describing a type of loop traversal.
LoopLevel()
Construct an undefined LoopLevel.
static LoopLevel inlined()
Construct a special LoopLevel value that implies that a function should be inlined away...
std::string var
The var in the pure definition corresponding to this axis.
const std::vector< Split > & splits() const
The traversal of the domain of a function can have some of its dimensions split into sub-dimensions...
bool allow_race_conditions() const
Are race conditions permitted?
std::string to_string() const
Properties of one axis of the storage of a Func.
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...
A reference-counted handle to Halide's internal representation of a function.
Equivalent to RoundUp, but protected values that would be written beyond the end by loading the memor...
const std::vector< PrefetchDirective > & prefetches() const
You may perform prefetching in some of the dimensions of a function.
FuncSchedule(IntrusivePtr< FuncScheduleContents > c)
void mutate(IRMutator *)
Pass an IRMutator through to all Exprs referenced in the Schedule.
void accept(IRVisitor *) const
Pass an IRVisitor through to all Exprs referenced in the Schedule.
This represents two stages with fused loop nests from outermost to a specific loop level...
std::string func_name() const
bool match(const std::string &loop) const
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< StorageDim > & storage_dims() const
The list and order of dimensions used to store this function.
const FuseLoopLevel & fuse_level() const
Innermost loop level of fused loop nest for this function stage.
Equivalent to ShiftInwards, but protects values that would be re-evaluated by loading the memory loca...
A base class for passes over the IR which modify it (e.g.
bool is_pure() const
Can this loop be evaluated in any order (including in parallel)? Equivalently, are there no data haza...
std::string var
The loop var being bounded.
const std::vector< ReductionVariable > & rvars() const
RVars of reduction domain associated with this schedule if there is any.
DeviceAPI
An enum describing a type of device API.
The Dim struct represents one loop in the schedule's representation of a loop nest.
bool operator!=(const LoopLevel &other) const
bool operator<(const FusedPair &other) const
bool operator==(const LoopLevel &other) const
This dim originated from a Var.
MemoryType
An enum describing different address spaces to be used with Func::store_in.