Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
CostModel.h
Go to the documentation of this file.
1#ifndef COST_MODEL_H
2#define COST_MODEL_H
3
4#include <string>
5
6#include "FunctionDAG.h"
7#include "HalideBuffer.h"
8#include "PerfectHashMap.h"
9
10// An abstract base class for a cost model.
11namespace Halide {
12
13namespace Internal {
14namespace Autoscheduler {
15
17
19 /** Maximum level of parallelism available. */
20 int parallelism = 16;
21
22 /** Beam size to use in the beam search. Defaults to 32. Use 1 to get a greedy search instead.
23 * Formerly HL_BEAM_SIZE */
24 int beam_size = 32;
25
26 /** percent chance of accepting each state in the beam.
27 * Normalized by the number of decisions made, so 5 would be there's a 5 percent chance of never rejecting any states.
28 * Formerly HL_RANDOM_DROPOUT */
29 int random_dropout = 100;
30
31 /** Random seed used by the random dropout. If 0, use time().
32 * Formerly HL_SEED */
34
35 /** When training or schedule, read weights from this directory or file.
36 * (If path ends in `.weights` it is written as a single file, otherwise a directory of files.)
37 * Formerly HL_WEIGHTS_DIR */
38 std::string weights_path;
39
40 /** If set to nonzero value: limits the search space to that of Mullapudi et al.
41 * Formerly HL_NO_SUBTILING */
43
44 /** If set to nonzero value, only a random subset of the generated tilings for each stage will be accepted into the beam.
45 * Formerly HL_RANDOMIZE_TILINGS */
47
48 /** Expects a string of four 0/1 values that allow/disallow the following options:
49 * compute root, inline, compute at the block level, compute at the thread level
50 * e.g. 1000 would allow compute root only
51 * Formerly HL_SEARCH_SPACE_OPTIONS */
52 std::string search_space_options = "1111";
53
54 /** If set to nonzero value, run a pre-pass where only compute_root and inline scheduling options are considered.
55 * Formerly HL_FREEZE_INLINE_COMPUTE_ROOT */
57
58 /** If nonempty, load the initial (partial) schedule from the given file.
59 * Formerly PARTIAL_SCHEDULE */
61
62 /** User-requested specific number of passes. Ignored if 0.
63 * Formerly HL_NUM_PASSES */
64 int num_passes = 0;
65
66 /** TODO: document me
67 * Formerly HL_STACK_FACTOR */
68 double stack_factor = 0.95f;
69
70 /** TODO: document me
71 * Formerly HL_SHARED_MEMORY_LIMIT */
73
74 /** TODO: document me
75 * Formerly HL_SHARED_MEMORY_SM_LIMIT */
77
78 /** TODO: document me
79 * Formerly HL_ACTIVE_BLOCK_LIMIT */
81
82 /** TODO: document me
83 * Formerly HL_ACTIVE_WARP_LIMIT */
85};
86
87} // namespace Autoscheduler
88} // namespace Internal
89
90class CostModel {
91public:
92 virtual ~CostModel() = default;
93
94 // Configure the cost model for the algorithm to be scheduled.
97
98 // Enqueue a schedule to be evaluated. Will annotate the value located at cost_ptr when the evaluation takes place.
99 // Note that the dag argument should correspond to the dag specified previously when calling set_pipeline_features.
102 double *cost_ptr,
103 std::vector<double> *cost_per_stage_ptr) = 0;
104
105 // Evaluate all schedules in the queue.
106 virtual void evaluate_costs() = 0;
107
108 // Discard all schedules in the queue.
109 virtual void reset() = 0;
110};
111
112} // namespace Halide
113
114#endif // COST_MODEL_H
Defines a Buffer type that wraps from halide_buffer_t and adds functionality, and methods for more co...
virtual void set_pipeline_features(const Internal::Autoscheduler::FunctionDAG &dag, const Internal::Autoscheduler::Anderson2021Params &params)=0
virtual ~CostModel()=default
virtual void enqueue(const Internal::Autoscheduler::FunctionDAG &dag, const Halide::Internal::Autoscheduler::StageMapOfScheduleFeatures &schedule_feats, double *cost_ptr, std::vector< double > *cost_per_stage_ptr)=0
virtual void reset()=0
virtual void evaluate_costs()=0
PerfectHashMap< FunctionDAG::Node::Stage, ScheduleFeatures > StageMapOfScheduleFeatures
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
signed __INT64_TYPE__ int64_t
int random_dropout
percent chance of accepting each state in the beam.
Definition CostModel.h:29
int shared_memory_limit_kb
TODO: document me Formerly HL_SHARED_MEMORY_LIMIT.
Definition CostModel.h:72
int randomize_tilings
If set to nonzero value, only a random subset of the generated tilings for each stage will be accepte...
Definition CostModel.h:46
std::string weights_path
When training or schedule, read weights from this directory or file.
Definition CostModel.h:38
int parallelism
Maximum level of parallelism available.
Definition CostModel.h:20
int num_passes
User-requested specific number of passes.
Definition CostModel.h:64
std::string search_space_options
Expects a string of four 0/1 values that allow/disallow the following options: compute root,...
Definition CostModel.h:52
int freeze_inline_compute_root
If set to nonzero value, run a pre-pass where only compute_root and inline scheduling options are con...
Definition CostModel.h:56
int shared_memory_sm_limit_kb
TODO: document me Formerly HL_SHARED_MEMORY_SM_LIMIT.
Definition CostModel.h:76
double stack_factor
TODO: document me Formerly HL_STACK_FACTOR.
Definition CostModel.h:68
int64_t random_dropout_seed
Random seed used by the random dropout.
Definition CostModel.h:33
int beam_size
Beam size to use in the beam search.
Definition CostModel.h:24
int disable_subtiling
If set to nonzero value: limits the search space to that of Mullapudi et al.
Definition CostModel.h:42
int active_block_limit
TODO: document me Formerly HL_ACTIVE_BLOCK_LIMIT.
Definition CostModel.h:80
std::string partial_schedule_path
If nonempty, load the initial (partial) schedule from the given file.
Definition CostModel.h:60
int active_warp_limit
TODO: document me Formerly HL_ACTIVE_WARP_LIMIT.
Definition CostModel.h:84