Halide
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. ProvideValueSubstitution and
24  // ProvideArgSubstitution are similar, but only apply to instances
25  // found on the LHS or RHS of a call or provide. respectively. If
26  // type is "LetStmt", we should insert a new let stmt defining
27  // "name" with value "value". If type is "Predicate", we should
28  // ignore "name" and the predicate is "value".
29 
30  std::string name;
32 
33  enum Type { Substitution = 0,
41 
42  ApplySplitResult(const std::string &n, Expr val, Type t)
43  : name(n), value(std::move(val)), type(t) {
44  }
46  : name(""), value(std::move(val)), type(t) {
47  }
48 
49  bool is_substitution() const {
50  return (type == Substitution);
51  }
52  bool is_substitution_in_calls() const {
53  return (type == SubstitutionInCalls);
54  }
56  return (type == SubstitutionInProvides);
57  }
58  bool is_let() const {
59  return (type == LetStmt);
60  }
61  bool is_predicate() const {
62  return (type == Predicate);
63  }
64  bool is_predicate_calls() const {
65  return (type == PredicateCalls);
66  }
67  bool is_predicate_provides() const {
68  return (type == PredicateProvides);
69  }
70 };
71 
72 /** Given a Split schedule on a definition (init or update), return a list of
73  * of predicates on the definition, substitutions that needs to be applied to
74  * the definition (in ascending order of application), and let stmts which
75  * defined the values of variables referred by the predicates and substitutions
76  * (ordered from innermost to outermost let). */
77 std::vector<ApplySplitResult> apply_split(
78  const Split &split, bool is_update, const std::string &prefix,
79  std::map<std::string, Expr> &dim_extent_alignment);
80 
81 /** Compute the loop bounds of the new dimensions resulting from applying the
82  * split schedules using the loop bounds of the old dimensions. */
83 std::vector<std::pair<std::string, Expr>> compute_loop_bounds_after_split(
84  const Split &split, const std::string &prefix);
85 
86 } // namespace Internal
87 } // namespace Halide
88 
89 #endif
Halide::Internal::ApplySplitResult::is_substitution_in_provides
bool is_substitution_in_provides() const
Definition: ApplySplit.h:55
Halide::Internal::ApplySplitResult::is_predicate_calls
bool is_predicate_calls() const
Definition: ApplySplit.h:64
Halide::Internal::ApplySplitResult::is_substitution_in_calls
bool is_substitution_in_calls() const
Definition: ApplySplit.h:52
Halide::Internal::ApplySplitResult::name
std::string name
Definition: ApplySplit.h:30
Halide::Internal::ApplySplitResult::PredicateProvides
@ PredicateProvides
Definition: ApplySplit.h:38
Halide::Internal::LetStmt
The statement form of a let node.
Definition: IR.h:274
Halide::Internal::ApplySplitResult::Substitution
@ Substitution
Definition: ApplySplit.h:33
Halide::Internal::ApplySplitResult::value
Expr value
Definition: ApplySplit.h:31
Schedule.h
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::ApplySplitResult::is_let
bool is_let() const
Definition: ApplySplit.h:58
Halide::Internal::ApplySplitResult::SubstitutionInProvides
@ SubstitutionInProvides
Definition: ApplySplit.h:35
Halide::Internal::ApplySplitResult::ApplySplitResult
ApplySplitResult(Expr val, Type t=Predicate)
Definition: ApplySplit.h:45
Halide::Internal::ApplySplitResult::ApplySplitResult
ApplySplitResult(const std::string &n, Expr val, Type t)
Definition: ApplySplit.h:42
Halide::Internal::ApplySplitResult::LetStmt
@ LetStmt
Definition: ApplySplit.h:36
Halide::Internal::ApplySplitResult::is_substitution
bool is_substitution() const
Definition: ApplySplit.h:49
Halide::Internal::ApplySplitResult::type
Type type
Definition: ApplySplit.h:40
Halide::Internal::ApplySplitResult::Predicate
@ Predicate
Definition: ApplySplit.h:39
Expr.h
Halide::Internal::ApplySplitResult::PredicateCalls
@ PredicateCalls
Definition: ApplySplit.h:37
Halide::Internal::ApplySplitResult
Definition: ApplySplit.h:21
Halide::Internal::ApplySplitResult::SubstitutionInCalls
@ SubstitutionInCalls
Definition: ApplySplit.h:34
Halide::Internal::apply_split
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...
Halide::Internal::ApplySplitResult::is_predicate
bool is_predicate() const
Definition: ApplySplit.h:61
Halide::Internal::ApplySplitResult::is_predicate_provides
bool is_predicate_provides() const
Definition: ApplySplit.h:67
Halide::Internal::ApplySplitResult::Type
Type
Definition: ApplySplit.h:33
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:257
Halide::Internal::compute_loop_bounds_after_split
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...