Loading...
Searching...
No Matches
Solve.h
Go to the documentation of this file.
#ifndef SOLVE_H
#define SOLVE_H
/** Defines methods for manipulating and analyzing boolean expressions. */
#include "Bounds.h"
#include "Expr.h"
#include "Interval.h"
#include "Scope.h"
namespace Halide {
namespace Internal {
struct SolverResult {
Expr result;
bool fully_solved;
};
/** Attempts to collect all instances of a variable in an expression
* tree and place it as far to the left as possible, and as far up the
* tree as possible (i.e. outside most parentheses). If the expression
* is an equality or comparison, this 'solves' the equation. Returns a
* pair of Expr and bool. The Expr is the mutated expression, and the
* bool indicates whether there is a single instance of the variable
* in the result. If it is false, the expression has only been partially
* solved, and there are still multiple instances of the variable. */
SolverResult solve_expression(
const Expr &e, const std::string &variable,
const Scope<Expr> &scope = Scope<Expr>::empty_scope());
/** Find the smallest interval such that the condition is either true
* or false inside of it, but definitely false outside of it. Never
* returns undefined Exprs, instead it uses variables called "pos_inf"
* and "neg_inf" to represent positive and negative infinity. */
Interval solve_for_outer_interval(const Expr &c, const std::string &variable);
/** Find the largest interval such that the condition is definitely
* true inside of it, and might be true or false outside of it. */
Interval solve_for_inner_interval(const Expr &c, const std::string &variable);
/** Take a conditional that includes variables that vary over some
* domain, and convert it to a more conservative (less frequently
* true) condition that doesn't depend on those variables. Formally,
* the output expr implies the input expr.
*
* The condition may be a vector condition, in which case we also
* 'and' over the vector lanes, and return a scalar result. */
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 weaker (less frequently false) condition
* that doesn't depend on those variables. Formally, the input expr
* implies the output expr. Note that this function might be unable to
* provide a better response than simply const_true(). */
Expr or_condition_over_domain(const Expr &c, const Scope<Interval> &varying);
void solve_test();
} // namespace Internal
} // namespace Halide
#endif
Bounds.h
Methods for computing the upper and lower bounds of an expression, and the regions of a function read...
Expr.h
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt).
Interval.h
Defines the Interval class.
Scope.h
Defines the Scope class, which is used for keeping track of names in a scope while traversing IR.
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 Scope.h:94
Halide::Internal::Scope::empty_scope
static const Scope< T > & empty_scope()
A const ref to an empty scope.
Definition Scope.h:120
Halide::Internal
Definition AbstractGenerator.h:24
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::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...
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_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,...
Halide::Internal::solve_test
void solve_test()
Halide::Internal::or_condition_over_domain
Expr or_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 weaker (le...
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258
Halide::Internal::Interval
A class to represent ranges of Exprs.
Definition Interval.h:14
Halide::Internal::SolverResult
Definition Solve.h:14
Halide::Internal::SolverResult::fully_solved
bool fully_solved
Definition Solve.h:16
Halide::Internal::SolverResult::result
Expr result
Definition Solve.h:15