Go to the documentation of this file.
22 namespace Autoscheduler {
27 using std::unique_ptr;
33 struct OptionalRational {
58 numerator += other.numerator * (l / other.denominator);
112 return !((*this) <= x);
119 return !((*this) < x);
134 std::vector<OptionalRational> coeffs;
141 coeffs.resize(rows * cols);
145 for (
const auto &coeff : coeffs) {
146 if (!coeff.exists()) {
166 for (
const auto &c : coeffs) {
167 if (!c.exists() || !(c == 0)) {
180 return coeffs[producer_storage_dim * cols + consumer_loop_dim];
184 return coeffs[producer_storage_dim * cols + consumer_loop_dim];
197 if (other.rows != rows || other.cols != cols) {
200 for (
size_t i = 0; i < rows * cols; i++) {
201 if (!(other.coeffs[i] == coeffs[i])) {
214 result(i, j) = (*this)(i, j) * factors[j];
225 for (
size_t j = 0; j < other.consumer_loop_dims(); j++) {
228 result(i, j) += (*this)(i, k) * other(k, j);
235 void dump(
const char *prefix)
const;
254 bool constant_extent_;
264 return max_ - min_ + 1;
267 return constant_extent_;
273 constant_extent_ = constant_extent_ && other.constant_extent();
286 : min_(a), max_(b), constant_extent_(c) {
291 return Span(INT64_MAX, INT64_MIN,
true);
300 struct BoundContents {
304 const Layout *
layout =
nullptr;
351 mutable std::vector<BoundContents *> pool;
354 mutable std::vector<void *> blocks;
356 mutable size_t num_live = 0;
358 void allocate_some_more()
const;
386 using Bound = IntrusivePtr<const BoundContents>;
396 struct SymbolicInterval {
426 struct RegionComputedInfo {
511 :
stage(std::move(s)) {
516 for (
const auto &l :
loop) {
581 vector<pair<BoundInfo, BoundInfo>>
bounds;
601 void expand_footprint(
const Span *consumer_loop, Span *producer_required)
const;
619 std::ostream &
dump(std::ostream &os)
const;
629 template<
typename OS>
630 void dump_internal(OS &os)
const;
675 int visit_nary(
const std::vector<Expr> &exprs);
690 #endif // FUNCTION_DAG_H
signed __INT32_TYPE__ int32_t
int compute(const Function &f)
LoadJacobian(size_t producer_storage_dims, size_t consumer_loop_dims, int64_t count)
The sum of two expressions.
bool operator>(int x) const
A Halide variable, to be used when defining functions.
bool region_computed_all_common_cases
vector< bool > dependencies
Horizontally reduce a vector to a scalar or narrower vector using the given commutative and associati...
PipelineFeatures features
BoundContents * make_copy() const
Is the first expression greater than or equal to the second.
ExprBranching(const NodeMap< int64_t > &inlined)
LoadJacobian operator*(const std::vector< int64_t > &factors) const
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
vector< Edge * > outgoing_edges
std::unique_ptr< LoadJacobian > store_jacobian
Floating point constants.
void operator+=(const OptionalRational &other)
A vector with 'lanes' elements, in which every element is 'value'.
The ratio of two expressions.
size_t consumer_loop_dims() const
bool all_coeffs_exist() const
void loop_nest_for_region(int stage_idx, const Span *computed, Span *loop) const
bool equals_union_of_required_with_constants
void sanitize_names(std::string &str)
Span & region_computed(int i)
The actual IR nodes begin here.
Is the first expression less than or equal to the second.
BoundContents * make() const
FunctionDAG(const vector< Function > &outputs, const Target &target)
Is the first expression not equal to the second.
FunctionDAG::Node * producer
OptionalRational & operator()(int producer_storage_dim, int consumer_loop_dim)
void translate(int64_t x)
int64_t gcd(int64_t, int64_t)
The greatest common divisor of two integers.
Load a value from a named symbol if predicate is true.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
FunctionDAG & operator=(const FunctionDAG &other)=delete
Logical or - is at least one of the expression true.
Is the first expression equal to the second.
bool operator<=(int x) const
@ Internal
Not visible externally, similar to 'static' linkage in C.
The greater of two values.
IntrusivePtr< const BoundContents > Bound
OptionalRational operator()(int producer_storage_dim, int consumer_loop_dim) const
Span & region_required(int i)
void operator=(const Layout &)=delete
size_t producer_storage_dims() const
BoundContents * make_bound() const
A let expression, like you might find in a functional language.
bool operator>=(int x) const
A linear ramp vector node.
LoadJacobian operator*(const LoadJacobian &other) const
signed __INT64_TYPE__ int64_t
map< int, const Node * > stage_id_to_node_map
FunctionDAG::Node::Stage * consumer
void expand_footprint(const Span *consumer_loop, Span *producer_required) const
A visitor/mutator capable of passing arbitrary arguments to the visit methods using CRTP and returnin...
const Span & region_computed(int i) const
vector< Span > estimated_region_required
bool operator==(const OptionalRational &other) const
The lesser of two values.
BoundInfo(const Expr &e, const Node::Stage &consumer, bool dependent)
bool equals_region_computed
void add_load_jacobian(LoadJacobian j1)
bool constant_extent() const
vector< pair< BoundInfo, BoundInfo > > bounds
A reference-counted handle to Halide's internal representation of a function.
OptionalRational operator*(const OptionalRational &other) const
OptionalRational(int64_t n, int64_t d)
int64_t lcm(int64_t, int64_t)
The least common multiple of two integers.
bool loop_nest_all_common_cases
Span(int64_t a, int64_t b, bool c)
std::unique_ptr< BoundContents::Layout > bounds_memory_layout
int visit(const Reinterpret *op)
void * memcpy(void *s1, const void *s2, size_t n)
vector< Edge * > incoming_edges
Reinterpret value as another type, without affecting any of the bits (on little-endian systems).
bool is_boundary_condition
bool operator<(int x) const
A class representing a reference count to be used with IntrusivePtr.
A fragment of Halide syntax.
vector< RegionComputedInfo > region_computed
const Span & region_required(int i) const
vector< LoadJacobian > load_jacobians
int visit_nary(const std::vector< Expr > &exprs)
Is the first expression greater than the second.
vector< SymbolicInterval > region_required
Construct a new vector by taking elements from another sequence of vectors.
Span & loops(int i, int j)
void required_to_computed(const Span *required, Span *computed) const
void set_extent(int64_t e)
std::vector< int > loop_offset
int visit_binary(const Expr &a, const Expr &b)
Unsigned integer constants.
Expr max(const FuncRef &a, const FuncRef &b)
A single definition of a Func.
bool merge(const LoadJacobian &other)
bool operator==(int x) const
The difference of two expressions.
void union_with(const Span &other)
A struct representing a target machine and os to generate code for.
OptionalRational()=default
bool all_load_jacobian_coeffs_exist() const
bool downstream_of(const Node &n) const
Logical and - are both expressions true.
const Span & loops(int i, int j) const
OptionalRational operator*(int64_t factor) const
void release(const BoundContents *b) const
Logical not - true if the expression false.
Is the first expression less than the second.
void dump(std::ostream &os, const char *prefix) const
int get_loop_index_from_var(const std::string &var) const
The product of two expressions.