Index
Affine
¶
Bases: RowMap[C]
The features of each row of a basis followed by a 1, so a linear model of them adds a constant to the cost of each row.
Source code in src/finch/autoschedule/cost_models/cost_models.py
Basis
¶
A basis describes a logic statement by the features of its components, such as queries, loop prefixes, or tensor levels. components yields the components of a program, advancing the StatsMachine past each statement after yielding its components, and get_component_features gives a component one row of n_features for each independently priced part of it. Like a Stage, a Basis inherits the form of statements it accepts. ridge weights the penalty on the square of each coefficient of a linear model of the basis, and feature_names names each feature, by default by its index.
Source code in src/finch/autoschedule/cost_models/cost_models.py
ByKind
¶
Bases: Concat[C], Generic[C, K]
The features of each component under the basis of its kind, which key returns, by default the kind attribute of the component. The features of a component fill the columns of its basis, and the other columns are zero, so a linear model has separate coefficients for each kind.
Source code in src/finch/autoschedule/cost_models/cost_models.py
Concat
¶
Bases: Basis[C]
The features of several bases of the same kind of component, side by side.
Source code in src/finch/autoschedule/cost_models/cost_models.py
CostModel
¶
A linear cost model weights the features its basis gives the components of a logic statement by its coefficients, and sums over their rows, so the cost of a program is the sum of the costs of its components, which predict_component_cost prices one at a time. Runtimes are measured for whole programs, so fit takes the features of each program, as get_features returns them, with its runtime, and finds the nonnegative coefficients which minimize the sum of the squared relative errors of the predicted runtimes, so that fast programs count as much as slow ones, and the cost of a row of nonnegative features is nonnegative, penalized by alpha times the ridge weights of the basis. The runtimes must be positive, and a fit to no programs is zero. to_json writes the coefficients with the names of their features, which from_json checks against the basis of the model it reads them into.
Source code in src/finch/autoschedule/cost_models/cost_models.py
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
DenseLevelOption
¶
Bases: LevelOption
Storage features are positions and slots.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
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/protocol_cost_models.py
FactorizeBasis
¶
A basis 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
FlopsBasis
¶
Bases: FactorizeBasis, AliasedForm
FlopsBasis counts the non-fill values in the iteration space of each query, and in the output it materializes. Each query is a component.
Source code in src/finch/autoschedule/cost_models/factorize_cost_models.py
LevelOption
¶
Bases: ABC
A kind of level, which gives the storage features feature_names names, and the positions it passes to its child, from the stats of the tensor, the zero-based depth of the level, and the num_pos positions entering it. A tensor which stores one slice that fixes the fields of over is described by its largest slice. A level which filters has a fiber only where it has an entry, so a lookup which finds none runs nothing within it.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
LoopBasis
¶
A basis where each loop prefix, including the empty prefix, is a component, as prefixes yields them, and get_component_features returns one row for each prefix. Models used with branch-and-bound loop search must predict nonnegative component costs.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
LoopDepthBasis
¶
Bases: FactorizeBasis, AliasedForm
LoopDepthBasis counts the fields each query loops over, so that a greedy search reduces the indices which keep the deepest loop nest shallow. It needs only the shapes of its statistics. Each query is a component.
Source code in src/finch/autoschedule/cost_models/factorize_cost_models.py
LoopSpaces
¶
Bases: Generic[NS]
The spaces of the last loop of a nonempty loop prefix: where it is entered, what it visits, and where its walks step, from the stats of the tables it merges, restricted as their formats and protocols allow, as unrestricted says. A table whose formats the prefix doesn't list is taken to be sparse, and a table without protocols walks the field of the loop.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
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 167 168 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 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 | |
extent(stat, fields)
¶
The points of stat over fields, spanning all of those it lacks.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
located(stat, fields)
¶
The distinct points of stat at fields: the positions of a level of those fields which the loop reaches in stat, however often it runs.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
merged(node, fields=())
¶
Where a merge of the inputs of node visits parent and fields: where every fiber it merges has positions, as the formats give them.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
project(stat, fields=(), followed=())
¶
The support of stat over parent and fields, less the fields of followed, which it spans wholly.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
protocol(node)
¶
The protocol node reads the field of the loop with.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
stepped(table)
¶
The entries of table at idx which a walk of it steps through: those where the merge steps, since it steps through nothing where another fiber it merges has no positions.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
unrestricted(table, fields)
¶
The fields of fields which table doesn't restrict: the field of the loop where table follows it, since it is looked up wherever the others go, and those of the dense levels down to the deepest level of the rest, from the sparse level above them, which have a fiber at every slot of it, so the positions of the level are the entries of the sparse one, at every slot of the dense ones.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
visited()
¶
Where the loop visits idx, which its walks and gallops restrict.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
PigeonBasis
¶
Bases: LoopBasis, LoopOrderedForm
PigeonBasis counts iteration, operation, output, lookup, and dense iteration costs across loop prefixes. The empty prefix charges the non-fill values of the output once, and a nonempty prefix charges its last loop: a walk steps through the stored indices of its table, a gallop or a follow instead visits the indices where the expression runs, charging a lookup at each, and the dense iterations of a loop are those it would make if its tables were dense, so that none could restrict it: its whole extent, wherever its enclosing loops run.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
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, and output is the tensor it writes. formats, which bases that price formatted tensors need, lists the level options each alias stores, outermost first, as level_formats lists them.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
ProtocolBasis
¶
Bases: ByKind[ProtocolChoice, str]
The accesses of the levels of each formatted tensor, each under the basis of the kind of its level and, within it, of its protocol, so that a linear model prices each feature of an access by both.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
ProtocolChoice
dataclass
¶
An access of the level of a tensor at a zero-based stored depth by a query, at the last loop of prefix, which reaches the level: the last loop over a field of the levels from the root to it, or, for the element level at the rank of the tensor, to the last of them. table is the read, in the expression of prefix, or, if write, the table of the output of the query, and options are the kinds of the levels of the tensor, outermost first.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
Quadratic
¶
Bases: RowMap[C]
The products of each pair of features of each row of a basis, flattened row-major, so a linear model of them sums a quadratic form of each row.
Source code in src/finch/autoschedule/cost_models/cost_models.py
RowMap
¶
Bases: Basis[C]
A basis whose rows are a function, transform, of the rows of another basis for the same components.
Source code in src/finch/autoschedule/cost_models/cost_models.py
SparseByteMapLevelOption
¶
Bases: LevelOption
A bytemap flags each of its slots with a byte, and lists the slots which are occupied, so its children are allocated densely. Storage features are positions, slots, entries, and the bytes of its pointers and list.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
SparseHashLevelOption
¶
Bases: LevelOption
Storage features are positions, entries, position bytes, and index bytes.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
SparseListLevelOption
¶
Bases: LevelOption
Storage features are positions, entries, position bytes, and index bytes.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
Statement
dataclass
¶
StorageBasis
¶
Bases: ByKind[ProtocolChoice, str]
The storage of the levels each access writes, each under the basis of the kind of its level.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
Stratify
¶
Bases: RowMap[C]
The features of each row of a basis, in the block of columns of the regime of the row, with zeros in the blocks of the other regimes. The regime of a row is the number of thresholds its feature at index feature meets or exceeds. A linear model of this basis has separate coefficients for each regime, so a feature can cost differently once, say, the working set exceeds a cache.
Source code in src/finch/autoschedule/cost_models/cost_models.py
TransposeBasis
¶
Bases: LoopBasis, LoopOrderedForm
Count dense and sparse transposed entries, charging each input once per query, at the first prefix whose last loop reads it out of its stored order.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
allowed_options(alias, depth, term, options)
¶
The options which can take the level of alias at a depth in term: those which support the protocols term reads and writes it with.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
level_accesses(prefix, formats)
¶
The reads of levels at the last loop of prefix, then the writes of the levels of its output, if formats lists the options of its levels, with the write of its element level where the last of them is reached.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
level_formats(bindings)
¶
The options of the levels each alias of bindings stores, outermost first and ending with its element level, as the bases of formatted programs take them. A binding is either such a list, or a format, whose options level_options lists. An alias whose format stores a level of no option is left out.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
level_options(fmt)
¶
The options of the levels which a fiber tensor of the format fmt stores, outermost first and without its element level, or None where fmt isn't a fiber tensor or stores a level of no option.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
level_reads(prefix, formats)
¶
The levels which the tables of the query of prefix read at its last loop: those of the tensors of formats, whose options list the levels each alias stores, outermost first. A table which occurs several times reads each level once.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
nnz_after(stats, stats_factory, depth, over=())
¶
Return the non-fill entries of the first depth + 1 levels of stats, in the largest slice which fixes the fields of over.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
prefixes(term, machine, loop_order=(), formats=None)
¶
The loop prefixes of each query of term, including the empty prefix, in query order and from the shortest to the longest, advancing machine past each query after its prefixes. The loop order of a query is the fields of its enclosing Fuse nodes.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
read_options(option, idxs, nfused, depth, loop_order)
¶
The protocols which a table of idxs, whose first nfused fields are fused, can read a level of option at a zero-based stored depth with under loop_order. A walk or a gallop steps through the level at the loop over its field, so that loop must come after the loops over the fields of the levels above it. Otherwise the level is reached inside the loop over its field, where it can only be followed.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
read_protocols(alias, depth, term)
¶
The protocols which term reads the level of alias at a depth with. A read which gives no protocol takes whichever the level supports, which the protocol optimizer chooses, so it constrains nothing.
Source code in src/finch/autoschedule/cost_models/protocol_cost_models.py
write_protocols(alias, depth, term)
¶
The protocols which term writes the level of alias at a zero-based stored depth with, as util.write_protocols infers them under the loops of the enclosing Fuse nodes. An update which reduces into alias laminates what it already stores, but one which overwrites it or sets it to a literal starts it again.