Halide  19.0.0
Halide compiler and libraries
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 "Featurization.h"
7 #include "FunctionDAG.h"
8 #include "HalideBuffer.h"
9 #include "PerfectHashMap.h"
10 
11 // An abstract base class for a cost model.
12 namespace Halide {
13 
14 namespace Internal {
15 namespace Autoscheduler {
16 
18 
20  /** Maximum level of parallelism available. */
21  int parallelism = 16;
22 
23  /** Beam size to use in the beam search. Defaults to 32. Use 1 to get a greedy search instead.
24  * Formerly HL_BEAM_SIZE */
25  int beam_size = 32;
26 
27  /** percent chance of accepting each state in the beam.
28  * Normalized by the number of decisions made, so 5 would be there's a 5 percent chance of never rejecting any states.
29  * Formerly HL_RANDOM_DROPOUT */
30  int random_dropout = 100;
31 
32  /** Random seed used by the random dropout. If 0, use time().
33  * Formerly HL_SEED */
35 
36  /** When training or schedule, read weights from this directory or file.
37  * (If path ends in `.weights` it is written as a single file, otherwise a directory of files.)
38  * Formerly HL_WEIGHTS_DIR */
39  std::string weights_path;
40 
41  /** If set to nonzero value: limits the search space to that of Mullapudi et al.
42  * Formerly HL_NO_SUBTILING */
44 
45  /** If set to nonzero value: features of possible schedules are always recalculated, and are not cached across passes.
46  * Formerly HL_DISABLE_MEMOIZED_FEATURES */
48 
49  /** If set to nonzero value: tiling sizes are not cached across passes.
50  * Formerly HL_DISABLE_MEMOIZED_BLOCKS */
52 
53  /** If >= 0, only consider schedules that allocate at most this much memory (measured in bytes).
54  * Formerly HL_AUTOSCHEDULE_MEMORY_LIMIT */
56 };
57 
58 } // namespace Autoscheduler
59 } // namespace Internal
60 
61 class CostModel {
62 public:
63  virtual ~CostModel() = default;
64 
65  // Configure the cost model for the algorithm to be scheduled.
68 
69  // Enqueue a schedule to be evaluated. Will annotate the value located at cost_ptr when the evaluation takes place.
70  // Note that the dag argument should correspond to the dag specified previously when calling set_pipeline_features.
73  double *cost_ptr) = 0;
74 
75  // Evaluate all schedules in the queue.
76  virtual void evaluate_costs() = 0;
77 
78  // Discard all schedules in the queue.
79  virtual void reset() = 0;
80 };
81 
82 } // namespace Halide
83 
84 #endif // COST_MODEL_H
Defines a Buffer type that wraps from halide_buffer_t and adds functionality, and methods for more co...
virtual ~CostModel()=default
virtual void reset()=0
virtual void enqueue(const Internal::Autoscheduler::FunctionDAG &dag, const Halide::Internal::Autoscheduler::StageMapOfScheduleFeatures &schedule_feats, double *cost_ptr)=0
virtual void evaluate_costs()=0
virtual void set_pipeline_features(const Internal::Autoscheduler::FunctionDAG &dag, const Internal::Autoscheduler::Adams2019Params &params)=0
PerfectHashMap< FunctionDAG::Node::Stage, ScheduleFeatures > StageMapOfScheduleFeatures
Definition: AutoSchedule.h:12
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
std::string weights_path
When training or schedule, read weights from this directory or file.
Definition: CostModel.h:39
int disable_memoized_blocks
If set to nonzero value: tiling sizes are not cached across passes.
Definition: CostModel.h:51
int random_dropout
percent chance of accepting each state in the beam.
Definition: CostModel.h:30
int disable_subtiling
If set to nonzero value: limits the search space to that of Mullapudi et al.
Definition: CostModel.h:43
int beam_size
Beam size to use in the beam search.
Definition: CostModel.h:25
int64_t memory_limit
If >= 0, only consider schedules that allocate at most this much memory (measured in bytes).
Definition: CostModel.h:55
int disable_memoized_features
If set to nonzero value: features of possible schedules are always recalculated, and are not cached a...
Definition: CostModel.h:47
int random_dropout_seed
Random seed used by the random dropout.
Definition: CostModel.h:34
int parallelism
Maximum level of parallelism available.
Definition: CostModel.h:21