Go to the documentation of this file. 1 #ifndef HALIDE_IR_MUTATOR_H
2 #define HALIDE_IR_MUTATOR_H
43 std::vector<Expr>
mutate(
const std::vector<Expr> &exprs) {
116 std::vector<Expr>
mutate(
const std::vector<Expr> &exprs) {
122 template<
typename Mutator,
typename... Args>
124 Region new_bounds(bounds.size());
125 bool bounds_changed =
false;
127 for (
size_t i = 0; i < bounds.size(); i++) {
128 Expr old_min = bounds[i].min;
129 Expr old_extent = bounds[i].extent;
130 Expr new_min = mutator->mutate(old_min, std::forward<Args>(args)...);
131 Expr new_extent = mutator->mutate(old_extent, std::forward<Args>(args)...);
132 if (!new_min.
same_as(old_min)) {
133 bounds_changed =
true;
135 if (!new_extent.
same_as(old_extent)) {
136 bounds_changed =
true;
138 new_bounds[i] =
Range(new_min, new_extent);
140 return {new_bounds, bounds_changed};
Allocate a scratch area called with the given name, type, and size.
The sum of two expressions.
std::vector< Range > Region
A multi-dimensional box.
Horizontally reduce a vector to a scalar or narrower vector using the given commutative and associati...
Is the first expression greater than or equal to the second.
std::map< Stmt, Stmt, Stmt::Compare > stmt_replacements
Floating point constants.
A vector with 'lanes' elements, in which every element is 'value'.
The ratio of two expressions.
std::pair< Region, bool > mutate_region(Mutator *mutator, const Region &bounds, Args &&...args)
A helper function for mutator-like things to mutate regions.
We use the "curiously recurring template pattern" to avoid duplicated code in the IR Nodes.
The statement form of a let node.
The actual IR nodes begin here.
A single-dimensional span.
Is the first expression less than or equal to the second.
Is the first expression not equal to the second.
A pair of statements executed concurrently.
A reference-counted handle to a statement node.
A mutator that caches and reapplies previously-done mutations, so that it can handle graphs of IR tha...
Load a value from a named symbol if predicate is true.
Free the resources associated with the given buffer.
Allocate a multi-dimensional buffer of the given type and size.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Logical or - is at least one of the expression true.
Is the first expression equal to the second.
This defines the value of a function at a multi-dimensional location.
@ Internal
Not visible externally, similar to 'static' linkage in C.
The greater of two values.
A let expression, like you might find in a functional language.
A linear ramp vector node.
Stmt mutate(const Stmt &s) override
std::vector< Expr > mutate(const std::vector< Expr > &exprs)
std::map< Expr, Expr, ExprCompare > expr_replacements
virtual Expr visit(const IntImm *)
Evaluate and discard an expression, presumably because it has some side-effect.
std::pair< std::vector< Expr >, bool > mutate_with_changes(const std::vector< Expr > &)
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.
The lesser of two values.
This node is a helpful annotation to do with permissions.
A base class for passes over the IR which modify it (e.g.
If the 'condition' is false, then evaluate and return the message, which should be a call to an error...
std::vector< Expr > mutate(const std::vector< Expr > &exprs)
Reinterpret value as another type, without affecting any of the bits (on little-endian systems).
A fragment of Halide syntax.
Represent a multi-dimensional region of a Func or an ImageParam that needs to be prefetched.
Is the first expression greater than the second.
Lock all the Store nodes in the body statement.
Construct a new vector by taking elements from another sequence of vectors.
Unsigned integer constants.
The difference of two expressions.
Logical and - are both expressions true.
Logical not - true if the expression false.
Is the first expression less than the second.
virtual Expr mutate(const Expr &expr)
This is the main interface for using a mutator.
The product of two expressions.
A sequence of statements to be executed in-order.
virtual ~IRMutator()=default
HALIDE_ALWAYS_INLINE bool same_as(const IntrusivePtr &other) const