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
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 374 | |
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 nest: where it is entered, what it visits, and where its walks step, where the tables of followed span the field of the loop wholly, as they are looked up wherever the others go. A table whose formats the nest doesn't list is taken to be sparse.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
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 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 | |
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
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
visited()
¶
Where the loop visits idx, which its walks and gallops restrict.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
walked(node)
¶
Where the walks of node at the loop have fibers with entries, over parent, combined as node combines them, or None where it walks nothing. A merge of walks skips a fiber only where this is empty: under a product, wherever one walked fiber is; under a sum, only where all are.
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
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
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 its class, with zeros in the blocks of the other classes. classify gives the class of each of rows, an integer from 0 to n_classes - 1, from its features. A linear model of this basis has separate coefficients for each class, 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
WithCopies
¶
The rows of basis, where a prefix whose last loop reads a table out of the order it is stored in, the first time a prefix of the query does, also has the rows basis gives the copy concordize makes of it, so that a model of basis prices transposing the table as it prices any query which scatters.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
WriteBasis
¶
Bases: LoopBasis, LoopOrderedForm
The writes to the levels of the output of a query which the last loop of each prefix reaches: those whose fields, and those of the levels above them, the prefix loops over, the last of them last. Where the loops up to a level are its fields in storage order, the level is written once for each of its indices, in order, and otherwise its writes scatter, as util.write_protocols infers. The element level is written with its parent. Besides the writes, a row has the entries of the region of the output the writes scatter into, which WriteClasses classes it by, a slice over the fields after the leading ones the loops visit in storage order, which a workspace fused over those could hold, or none where nothing scatters, and the distinct entries of the levels reached. Sizes are products of the extents of the fields, where a field which no table has, such as a unit dimension of the output alone, has one index.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
WriteClasses
dataclass
¶
The class of each row of WriteBasis, whether the region its writes scatter into exceeds the region cutoff. The default cutoff is the most entries a workspace can reset and copy out cheaply.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
WriteStrata
¶
Bases: Stratify
The rows of WriteBasis in the classes of classes. A write which scatters into a region over the cutoff isn't staged in a workspace, but written into the output where it goes, so its region costs nothing.
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
loop_basis(classes=write_class)
¶
The basis of the loop model, whose writes are of the classes of the region cutoff of classes.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
loop_cost_model(data)
¶
The loop model of data, which fit_physical_data wrote, whose writes are classed by its region cutoff if it was tuned. The fit times each loop order with its inputs stored in that order, so a table read out of the order it is stored in costs, besides, what the model prices the copy concordize makes of it at.
Source code in src/finch/autoschedule/cost_models/loop_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
rescans_a_root(loops, reads, protocols)
¶
Whether reading reads with protocols at the last of loops, within the others, steps through the root level of a table, such as a vector, which has the same entries at every execution of the loop, where a sparse level of another read, whose fiber the enclosing loops choose, could lead the loop instead. A walk steps through the root again at every execution, and so does a gallop of it beside a walk, which ends no phase, or beside no other gallop; a gallop leapfrogging with that of another read doesn't. The length of the root is exact while DC stats bound the other fibers by the largest, so the model may price stepping through it below following it, which looks up only where the others lead. Reads whose protocols the program gives are not among reads.
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.