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