Halide  12.0.1
Halide compiler and libraries
ApplySplit.h
Go to the documentation of this file.
1 #ifndef APPLY_SPLIT_H
2 #define APPLY_SPLIT_H
3 
4 /** \file
5  *
6  * Defines method that returns a list of let stmts, substitutions, and
7  * predicates to be added given a split schedule.
8  */
9 
10 #include <map>
11 #include <string>
12 #include <utility>
13 #include <vector>
14 
15 #include "Expr.h"
16 #include "Schedule.h"
17 
18 namespace Halide {
19 namespace Internal {
20 
22  // If type is "Substitution", then this represents a substitution of
23  // variable "name" to value. If type is "LetStmt", we should insert a new
24  // let stmt defining "name" with value "value". If type is "Predicate", we
25  // should ignore "name" and the predicate is "value".
26 
27  std::string name;
29 
30  enum Type { Substitution = 0,
34 
35  ApplySplitResult(const std::string &n, Expr val, Type t)
36  : name(n), value(std::move(val)), type(t) {
37  }
39  : name(""), value(std::move(val)), type(Predicate) {
40  }
41 
42  bool is_substitution() const {
43  return (type == Substitution);
44  }
45  bool is_let() const {
46  return (type == LetStmt);
47  }
48  bool is_predicate() const {
49  return (type == Predicate);
50  }
51 };
52 
53 /** Given a Split schedule on a definition (init or update), return a list of
54  * of predicates on the definition, substitutions that needs to be applied to
55  * the definition (in ascending order of application), and let stmts which
56  * defined the values of variables referred by the predicates and substitutions
57  * (ordered from innermost to outermost let). */
58 std::vector<ApplySplitResult> apply_split(
59  const Split &split, bool is_update, const std::string &prefix,
60  std::map<std::string, Expr> &dim_extent_alignment);
61 
62 /** Compute the loop bounds of the new dimensions resulting from applying the
63  * split schedules using the loop bounds of the old dimensions. */
64 std::vector<std::pair<std::string, Expr>> compute_loop_bounds_after_split(
65  const Split &split, const std::string &prefix);
66 
67 } // namespace Internal
68 } // namespace Halide
69 
70 #endif
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt)
Defines the internal representation of the schedule for a function.
std::vector< std::pair< std::string, Expr > > compute_loop_bounds_after_split(const Split &split, const std::string &prefix)
Compute the loop bounds of the new dimensions resulting from applying the split schedules using the l...
std::vector< ApplySplitResult > apply_split(const Split &split, bool is_update, const std::string &prefix, std::map< std::string, Expr > &dim_extent_alignment)
Given a Split schedule on a definition (init or update), return a list of of predicates on the defini...
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
A fragment of Halide syntax.
Definition: Expr.h:256
ApplySplitResult(const std::string &n, Expr val, Type t)
Definition: ApplySplit.h:35
The statement form of a let node.
Definition: IR.h:264