Loading...
Searching...
No Matches
ConstantBounds.h
Go to the documentation of this file.
#ifndef HALIDE_CONSTANT_BOUNDS_H
#define HALIDE_CONSTANT_BOUNDS_H
#include "ConstantInterval.h"
#include "Expr.h"
#include "Scope.h"
/** \file
* Methods for computing compile-time constant int64_t upper and lower bounds of
* an expression. Cheaper than symbolic bounds inference, and useful for things
* like instruction selection.
*/
namespace Halide {
namespace Internal {
/** Deduce constant integer bounds on an expression. This can be useful to
* decide if, for example, the expression can be cast to another type, be
* negated, be incremented, etc without risking overflow.
*
* Also optionally accepts a scope containing the integer bounds of any
* variables that may be referenced, and a cache of constant integer bounds on
* known Exprs, which this function will update. The cache is helpful to
* short-circuit large numbers of redundant queries, but it should not be used
* in contexts where the same Expr object may take on different values within a
* single Expr (i.e. before uniquify_variable_names).
*/
ConstantInterval constant_integer_bounds(const Expr &e,
const Scope<ConstantInterval> &scope = Scope<ConstantInterval>::empty_scope(),
std::map<Expr, ConstantInterval, ExprCompare> *cache = nullptr);
} // namespace Internal
} // namespace Halide
#endif
ConstantInterval.h
Defines the ConstantInterval class, and operators on it.
Expr.h
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt).
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::constant_integer_bounds
ConstantInterval constant_integer_bounds(const Expr &e, const Scope< ConstantInterval > &scope=Scope< ConstantInterval >::empty_scope(), std::map< Expr, ConstantInterval, ExprCompare > *cache=nullptr)
Deduce constant integer bounds on an expression.
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::ConstantInterval
A class to represent ranges of integers.
Definition ConstantInterval.h:18