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