cost_models
ByKind
Bases: Combination[C], Generic[C, K]
Predict the cost of each component with the submodel of its kind, which key returns, by default the kind attribute of the component. The features of a component fill the columns of its submodel, and the other columns are zero, so the columns of a linear fit line up with the coefficients of each kind.
Source code in src/finch/autoschedule/cost_models/cost_models.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
Concat
Bases: Combination[C]
Predict the cost of each component from the features of all submodels.
Source code in src/finch/autoschedule/cost_models/cost_models.py
170 171 172 173 174 175 176 177 178 179 | |
CostModel
A cost model predicts the cost of a logic statement as a sum over its components, such as queries, loop prefixes, or tensor levels:
sum_c predict_component_cost(c)
Each stage decomposes programs into its own kind of component, and its searches price one component at a time. components yields the components of a program, advancing the StatsMachine past each statement after yielding its components. get_component_features returns X_c with shape (n_rows, n_features). By default, the predictor callable takes X_c and returns a scalar sum of independently modeled rows, including zero for an empty matrix. Like a Stage, a CostModel inherits the form of statements it accepts.
Source code in src/finch/autoschedule/cost_models/cost_models.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
DenseLevelOption
Bases: LevelOption
Storage features are positions and slots.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
ElementLevelOption
Bases: LevelOption
The element level at the rank of a tensor stores one value for each position. Storage features are values and value bytes.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
FactorizeCostModel
A cost model where each query statement is a component, in program order. get_component_features returns one row for each statement.
Source code in src/finch/autoschedule/cost_models/factorize_cost_models.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
FlopsCostModel
Bases: FactorizeCostModel, AliasedForm
FlopsCostModel counts the non-fill values in the iteration space of each query, and in the output it materializes. Each query is a component. By default, allocations are weighted 10x iterations.
Source code in src/finch/autoschedule/cost_models/factorize_cost_models.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
FormatCostModel
Bases: CostModel[LevelChoice]
A cost model where each level of each formatted alias is a component. bindings lists the level options of an alias, outermost first and ending with its element level, and the alias is formatted when it is first written.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
LevelChoice
dataclass
The choice of a level option at a zero-based depth of alias, with num_pos positions entering it, in a format whose positions take pos_size bytes. term is the program which reads and writes alias.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
LevelCostModel
Bases: FormatCostModel, LoopOrderedForm
The cost model of the levels of one type of option. Each level contributes an allocation row, and an access row for each query loop prefix that uses it. The features are the storage features of the option for the allocation, followed by sequential reads, scatter reads, sequential writes, and scatter writes for the accesses.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_access_features(alias, level, term, machine)
Return the accesses to alias at a zero-based depth in each query of term: sequential reads, scatter reads, sequential writes, and scatter writes, with one row per loop prefix that accesses the level in each query. Each access is counted by the PigeonCostModel iterations of the loops from the root to the current level. The element level is accessed with its parent.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
get_component_features(component, machine)
Return the allocation row of the level, followed by its access rows.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
LevelOption
Bases: ABC
A kind of level, which describes the storage of a level with n_features storage features, and the number of positions it passes to its child. Both depend on the stats of the tensor, the zero-based depth of the level, and the num_pos positions entering it. Storage features also depend on the bytes of an index of the level, and of a position and a value of the tensor.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
LoopCostModel
A cost model where each loop prefix, including the empty prefix, is a component. components yields prefixes in query order, from the shortest prefix to the longest, and get_component_features returns one row for each prefix. Predictors used with branch-and-bound loop search must predict nonnegative component costs.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
PigeonCostModel
Bases: LoopCostModel, LoopOrderedForm
PigeonCostModel counts iteration, operation, and output costs across loop prefixes. By default, allocations are weighted 10x reads and operations.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
get_component_features(component, machine)
Return the incremental features for an outermost-first loop prefix.
A nonempty prefix charges its last index, projecting execution and output onto prefix[:-1], as in the inside-out calculation. The empty prefix charges the output's non-fill values once. Summing all prefixes, including the empty one, gives the query's features.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Prefix
dataclass
An outermost-first loop prefix of expr, the right-hand side of a query. output_vars orders the output of the query, when there is one.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
29 30 31 32 33 34 35 36 37 38 | |
QuadraticPredictor
Sum row-wise quadratic forms, with flattened row-major coefficients.
Source code in src/finch/autoschedule/cost_models/cost_models.py
26 27 28 29 30 31 32 33 34 | |
SparseHashLevelOption
Bases: LevelOption
Storage features are positions, entries, position bytes, and index bytes.
Source code in src/finch/autoschedule/cost_models/format_cost_models.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Statement
dataclass
A Query or QueryInto of a program.
Source code in src/finch/autoschedule/cost_models/factorize_cost_models.py
28 29 30 31 32 | |
Sum
Bases: Combination[C]
Sum the costs that submodels predict for each component. The coefficients of linear submodels concatenate like their features.
Source code in src/finch/autoschedule/cost_models/cost_models.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
TransposeCostModel
Bases: LoopCostModel, LoopOrderedForm
Count dense and sparse transposed entries, charging each input once per query.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
get_component_features(component, machine)
Charge only the input transpositions newly forced by this prefix.
Deduplicate input tables within this prefix. Comparing with the parent prefix avoids charging them again at deeper loop levels. Empty prefixes have no transposition cost.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |