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. 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
Halide::Internal::ApplySplitResult::name
std::string name
Definition: ApplySplit.h:27
Halide::Internal::LetStmt
The statement form of a let node.
Definition: IR.h:264
Halide::Internal::ApplySplitResult::Substitution
@ Substitution
Definition: ApplySplit.h:30
Halide::Internal::ApplySplitResult::value
Expr value
Definition: ApplySplit.h:28
Schedule.h
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
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:45
Halide::Internal::ApplySplitResult::ApplySplitResult
ApplySplitResult(const std::string &n, Expr val, Type t)
Definition: ApplySplit.h:35
Halide::Internal::ApplySplitResult::LetStmt
@ LetStmt
Definition: ApplySplit.h:31
Halide::Internal::ApplySplitResult::is_substitution
bool is_substitution() const
Definition: ApplySplit.h:42
Halide::Internal::ApplySplitResult::type
Type type
Definition: ApplySplit.h:33
Halide::Internal::ApplySplitResult::Predicate
@ Predicate
Definition: ApplySplit.h:32
Expr.h
Halide::Internal::ApplySplitResult
Definition: ApplySplit.h:21
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:48
Halide::Internal::ApplySplitResult::Type
Type
Definition: ApplySplit.h:30
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:256
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...
Halide::Internal::ApplySplitResult::ApplySplitResult
ApplySplitResult(Expr val)
Definition: ApplySplit.h:38