Halide
Solve.h
Go to the documentation of this file.
1 #ifndef SOLVE_H
2 #define SOLVE_H
3 
4 /** Defines methods for manipulating and analyzing boolean expressions. */
5 
6 #include "Bounds.h"
7 #include "Expr.h"
8 #include "Interval.h"
9 #include "Scope.h"
10 
11 namespace Halide {
12 namespace Internal {
13 
14 struct SolverResult {
17 };
18 
19 /** Attempts to collect all instances of a variable in an expression
20  * tree and place it as far to the left as possible, and as far up the
21  * tree as possible (i.e. outside most parentheses). If the expression
22  * is an equality or comparison, this 'solves' the equation. Returns a
23  * pair of Expr and bool. The Expr is the mutated expression, and the
24  * bool indicates whether there is a single instance of the variable
25  * in the result. If it is false, the expression has only been partially
26  * solved, and there are still multiple instances of the variable. */
28  const Expr &e, const std::string &variable,
29  const Scope<Expr> &scope = Scope<Expr>::empty_scope());
30 
31 /** Find the smallest interval such that the condition is either true
32  * or false inside of it, but definitely false outside of it. Never
33  * returns undefined Exprs, instead it uses variables called "pos_inf"
34  * and "neg_inf" to represent positive and negative infinity. */
35 Interval solve_for_outer_interval(const Expr &c, const std::string &variable);
36 
37 /** Find the largest interval such that the condition is definitely
38  * true inside of it, and might be true or false outside of it. */
39 Interval solve_for_inner_interval(const Expr &c, const std::string &variable);
40 
41 /** Take a conditional that includes variables that vary over some
42  * domain, and convert it to a more conservative (less frequently
43  * true) condition that doesn't depend on those variables. Formally,
44  * the output expr implies the input expr.
45  *
46  * The condition may be a vector condition, in which case we also
47  * 'and' over the vector lanes, and return a scalar result. */
48 Expr and_condition_over_domain(const Expr &c, const Scope<Interval> &varying);
49 
50 void solve_test();
51 
52 } // namespace Internal
53 } // namespace Halide
54 
55 #endif
Scope.h
Halide::Internal::solve_for_inner_interval
Interval solve_for_inner_interval(const Expr &c, const std::string &variable)
Find the largest interval such that the condition is definitely true inside of it,...
Bounds.h
Halide::Internal::solve_for_outer_interval
Interval solve_for_outer_interval(const Expr &c, const std::string &variable)
Find the smallest interval such that the condition is either true or false inside of it,...
Halide::Internal::Scope
A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Le...
Definition: ModulusRemainder.h:17
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::Internal::SolverResult::fully_solved
bool fully_solved
Definition: Solve.h:16
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::SolverResult::result
Expr result
Definition: Solve.h:15
Halide::Internal::solve_expression
SolverResult solve_expression(const Expr &e, const std::string &variable, const Scope< Expr > &scope=Scope< Expr >::empty_scope())
Attempts to collect all instances of a variable in an expression tree and place it as far to the left...
Halide::Internal::solve_test
void solve_test()
Expr.h
Halide::Internal::Interval
A class to represent ranges of Exprs.
Definition: Interval.h:14
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:257
Interval.h
Halide::Internal::SolverResult
Definition: Solve.h:14
Halide::Internal::and_condition_over_domain
Expr and_condition_over_domain(const Expr &c, const Scope< Interval > &varying)
Take a conditional that includes variables that vary over some domain, and convert it to a more conse...