Loading...
Searching...
No Matches
Interval.h
Go to the documentation of this file.
#ifndef HALIDE_INTERVAL_H
#define HALIDE_INTERVAL_H
/** \file
* Defines the Interval class
*/
#include "Expr.h"
namespace Halide {
namespace Internal {
/** A class to represent ranges of Exprs. Can be unbounded above or below. */
struct Interval {
/** Exprs to represent positive and negative infinity */
#ifdef COMPILING_HALIDE
static HALIDE_ALWAYS_INLINE Expr pos_inf() {
return pos_inf_expr;
}
static HALIDE_ALWAYS_INLINE Expr neg_inf() {
return neg_inf_expr;
}
#else
static Expr pos_inf() {
return pos_inf_noinline();
}
static Expr neg_inf() {
return neg_inf_noinline();
}
#endif
/** The lower and upper bound of the interval. They are included
* in the interval. */
Expr min, max;
/** A default-constructed Interval is everything */
Interval()
: min(neg_inf()), max(pos_inf()) {
}
/** Construct an interval from a lower and upper bound. */
Interval(const Expr &min, const Expr &max)
: min(min), max(max) {
internal_assert(min.defined() && max.defined());
}
/** The interval representing everything. */
static Interval everything();
/** The interval representing nothing. */
static Interval nothing();
/** Construct an interval representing a single point */
static Interval single_point(const Expr &e);
/** Is the interval the empty set */
bool is_empty() const;
/** Is the interval the entire range */
bool is_everything() const;
/** Is the interval just a single value (min == max) */
bool is_single_point() const;
/** Is the interval a particular single value */
bool is_single_point(const Expr &e) const;
/** Does the interval have a finite least upper bound */
bool has_upper_bound() const;
/** Does the interval have a finite greatest lower bound */
bool has_lower_bound() const;
/** Does the interval have a finite upper and lower bound */
bool is_bounded() const;
/** Is the interval the same as another interval */
bool same_as(const Interval &other) const;
/** Expand the interval to include another Interval */
void include(const Interval &i);
/** Expand the interval to include an Expr */
void include(const Expr &e);
/** Construct the smallest interval containing two intervals. */
static Interval make_union(const Interval &a, const Interval &b);
/** Construct the largest interval contained within two other intervals. */
static Interval make_intersection(const Interval &a, const Interval &b);
/** An eagerly-simplifying max of two Exprs that respects infinities. */
static Expr make_max(const Expr &a, const Expr &b);
/** An eagerly-simplifying min of two Exprs that respects infinities. */
static Expr make_min(const Expr &a, const Expr &b);
/** Equivalent to same_as. Exists so that the autoscheduler can
* compare two map<string, Interval> for equality in order to
* cache computations. */
bool operator==(const Interval &other) const;
private:
static Expr neg_inf_expr, pos_inf_expr;
// Never used inside libHalide; provided for Halide tests, to avoid needing to export
// data fields in some build environments.
static Expr pos_inf_noinline();
static Expr neg_inf_noinline();
};
} // namespace Internal
} // namespace Halide
#endif
internal_assert
#define internal_assert(c)
Definition Error.h:218
Expr.h
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt).
HALIDE_ALWAYS_INLINE
#define HALIDE_ALWAYS_INLINE
Definition HalideRuntime.h:49
Halide::Internal
Definition AbstractGenerator.h:24
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::single_point
static Interval single_point(const Expr &e)
Construct an interval representing a single point.
Halide::Internal::Interval::include
void include(const Interval &i)
Expand the interval to include another Interval.
Halide::Internal::Interval::operator==
bool operator==(const Interval &other) const
Equivalent to same_as.
Halide::Internal::Interval::make_union
static Interval make_union(const Interval &a, const Interval &b)
Construct the smallest interval containing two intervals.
Halide::Internal::Interval::make_intersection
static Interval make_intersection(const Interval &a, const Interval &b)
Construct the largest interval contained within two other intervals.
Halide::Internal::Interval::min
Expr min
The lower and upper bound of the interval.
Definition Interval.h:35
Halide::Internal::Interval::Interval
Interval(const Expr &min, const Expr &max)
Construct an interval from a lower and upper bound.
Definition Interval.h:43
Halide::Internal::Interval::nothing
static Interval nothing()
The interval representing nothing.
Halide::Internal::Interval::everything
static Interval everything()
The interval representing everything.
Halide::Internal::Interval::has_lower_bound
bool has_lower_bound() const
Does the interval have a finite greatest lower bound.
Halide::Internal::Interval::pos_inf
static Expr pos_inf()
Exprs to represent positive and negative infinity.
Definition Interval.h:25
Halide::Internal::Interval::same_as
bool same_as(const Interval &other) const
Is the interval the same as another interval.
Halide::Internal::Interval::is_single_point
bool is_single_point(const Expr &e) const
Is the interval a particular single value.
Halide::Internal::Interval::include
void include(const Expr &e)
Expand the interval to include an Expr.
Halide::Internal::Interval::is_empty
bool is_empty() const
Is the interval the empty set.
Halide::Internal::Interval::is_everything
bool is_everything() const
Is the interval the entire range.
Halide::Internal::Interval::neg_inf
static Expr neg_inf()
Definition Interval.h:28
Halide::Internal::Interval::make_min
static Expr make_min(const Expr &a, const Expr &b)
An eagerly-simplifying min of two Exprs that respects infinities.
Halide::Internal::Interval::make_max
static Expr make_max(const Expr &a, const Expr &b)
An eagerly-simplifying max of two Exprs that respects infinities.
Halide::Internal::Interval::has_upper_bound
bool has_upper_bound() const
Does the interval have a finite least upper bound.
Halide::Internal::Interval::is_single_point
bool is_single_point() const
Is the interval just a single value (min == max).
Halide::Internal::Interval::is_bounded
bool is_bounded() const
Does the interval have a finite upper and lower bound.
Halide::Internal::Interval::max
Expr max
Definition Interval.h:35
Halide::Internal::Interval::Interval
Interval()
A default-constructed Interval is everything.
Definition Interval.h:38