loop_cost_models
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
LoopNest
¶
Bases: Generic[NS]
Where the loops of a loop prefix of arg, an expression without protocols, are entered, as the formats of its tables allow, whatever protocols read them. The merge of a nest is where every fiber merged has positions at the fields of the prefix, so the loop over the next field is entered there, and the loop over the last field is entered where the merge of its parent, the nest of the prefix without it, has positions. The root, the nest of the empty prefix, keeps the stats of the inputs of arg, the extent of each field, and the field of each level of each table and whether it doesn't filter, outermost first, where the formats list level options. The spaces of the last loop under each set of followed tables are kept in spaces.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
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 | |
merged(node, followed=frozenset())
¶
Where a merge of the inputs of node visits the fields of the prefix: where every fiber it merges has positions, as the formats give them, and the tables of followed span the last field wholly.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
unrestricted(table, follows)
¶
The fields of the prefix which table doesn't restrict: the last, 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
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
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
loop_arg(expr)
¶
The expression the loops of a query merge: its aggregate's argument.
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
loop_spaces(component, machine)
¶
The LoopSpaces of the last loop of component, a nonempty prefix, on the nest of its loops, which extends the nests of their prefixes. The cache of machine keeps the nests by the expression they merge, the density of its levels and the stats it binds, and then by loop prefix, so the prefixes of a search share them however their tables read their fields, as do formats which agree on which levels are dense.
Source code in src/finch/autoschedule/cost_models/loop_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
restrict(stats_factory, stat, fields)
¶
The support of stat over fields, reducing the rest away.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
transpose_copy(tns, stat, prefix)
¶
The copy concordize makes of tns, of stats stat, read out of the order it is stored in under prefix, as with_copy_loop_orders orders it: in the order tns stores, into a tensor which stores the fields prefix visits first, in its order, and then the rest, as tns stores them.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
transposed(component, machine)
¶
The tensor of each table which the last loop of component reads out of the order it is stored in, the first time a prefix of the query does, with the stats of the table.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
unprotocoled(expr)
¶
expr, with every table reading its fields without protocols.
Source code in src/finch/autoschedule/cost_models/loop_cost_models.py
written_fields(component)
¶
The fields of the output of the query of component, in the order it stores them, which are those of its expression without output_vars.