stages
AliasedForm
¶
Bases: Form
AliasedForm requires that all aliases in the input are defined in the bindings or in previous queries and that all Tables are wrapping Aliases. Defining an alias selects its view, which is either the HardAlias or a FusedAlias with some number of fused dimensions, and invalidates every other view of that alias. Statements may only read or update the current view of an alias. Bindings define the HardAlias view.
Every Fuse node is in FusedForm. A FusedAlias defined within Fuse nodes stores a slice for each value of its fused fields, so it can only be read within the Fuse nodes of those fields which define it. The reset of a definition or overwrite runs before the outermost Fuse over a field which its lhs stores or which is reduced into it, so it can't read a dynamic fill of a tensor which that Fuse defines.
Source code in src/finch/autoschedule/stages.py
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 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 | |
CompilerForm
¶
Bases: FormattedForm
CompilerForm is the input of the notation lowerer. It is a FormattedForm whose statements, but the final Produces, are queries or Fuse nodes whose bodies are Plans of them in FusedForm: Query(Table(lhs, idxs), Table(arg, _)) copies arg into lhs, from the fill of arg. Query(Table(lhs, idxs), Aggregate(op, init, arg, _)) reduces arg into lhs with op, from init, a 0-D expression without aggregates or reorders. QueryInto(Table(lhs, _), overwrite, Literal(init)) sets every element of lhs to init. QueryInto(Table(lhs, idxs), op, arg) reduces arg into lhs with op. The fields of arg which idxs lacks are reduced. arg is made of Tables, Literals, and MapJoins, and a query can't read the alias it writes.
Source code in src/finch/autoschedule/stages.py
FormattedForm
¶
Bases: LoopOrderedForm
FormattedForm requires that the input query has had its tensor formats set. Every alias must have a TensorFType in the bindings. The valid forms of a query are those of LoopOrderedForm. The rank of each TensorFType is the number of fields which the views of its alias store.
Source code in src/finch/autoschedule/stages.py
FusedForm
¶
Bases: Form
A Fuse runs its body once for each value of its field, and deleting it doesn't change the meaning of a program. So a Fuse field isn't fused again within its body, every statement of its body uses it, and it occurs in a HardAlias table of its body, which gives its extent. The leading n indices of every FusedAlias table match the first n enclosing Fuse fields, from outermost to innermost.
Every iteration of a Fuse shares the tensors which its body stores along its field, or reduces it into, so they cannot occur on both lhs and rhs in its body, and only one statement of its body may reduce into a tensor. A definition which broadcasts the Fuse field, which its rhs lacks, has extent 1 in it, so it is the only statement of its body. Different alias views refer to the same tensor for these checks, which apply independently of the query's lowering stage.
Source code in src/finch/autoschedule/stages.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | |
LogicEinsumLowerer
¶
Bases: FormattedForm, Stage
Source code in src/finch/autoschedule/stages.py
lower(prgm, bindings, stats, stats_factory)
abstractmethod
¶
Generate Einsum Notation from the given logic and input types. Also return a dictionary including additional tables needed to run the kernel.
Source code in src/finch/autoschedule/stages.py
LogicFactorizer
¶
Bases: ScopedForm, LogicLoader
Source code in src/finch/autoschedule/stages.py
lower(prgm, bindings, stats, stats_factory)
abstractmethod
¶
Optimize the aggregate structure of the given logic statement and make decisions about materialization.
Source code in src/finch/autoschedule/stages.py
LogicFormatter
¶
Bases: LoopOrderedForm, LogicLoader
Source code in src/finch/autoschedule/stages.py
lower(prgm, bindings, stats, stats_factory)
abstractmethod
¶
Optimize the tensor formats and output orders for each query.
Source code in src/finch/autoschedule/stages.py
LogicLoopOrderer
¶
Bases: SingleAggregateForm, LogicLoader
Source code in src/finch/autoschedule/stages.py
lower(prgm, bindings, stats, stats_factory)
abstractmethod
¶
Optimize the loop order of each query and add transposes where necessary.
Source code in src/finch/autoschedule/stages.py
LogicNotationLowerer
¶
Bases: CompilerForm, Stage
Source code in src/finch/autoschedule/stages.py
lower(term, bindings, stats, stats_factory)
abstractmethod
¶
Generate Finch Notation from the given logic and input types. Also return a dictionary including additional tables needed to run the kernel.
Source code in src/finch/autoschedule/stages.py
LoopOrderedForm
¶
Bases: SingleAggregateForm
LoopOrderedForm assumes that each query has its loop order: the fields of its enclosing Fuse nodes, from outermost to innermost, which include every field of the query. A query is a copy Query(lhs, Table), a reduction Query(lhs, Aggregate), an update QueryInto(lhs, op, arg), or an initialization QueryInto(lhs, op, Literal), which needs no loop order. Tables may be read and written in any order. Queries have no Reorder nodes.
Source code in src/finch/autoschedule/stages.py
ScopedForm
¶
Bases: AliasedForm
ScopedForm requires that the fields an aggregate reduces appear nowhere outside it, unless an enclosing Fuse loops over them, so that a rewrite can move an aggregate without capturing a field of the same name. normalize_names renames the fields of each aggregate apart to put a program in ScopedForm.
Source code in src/finch/autoschedule/stages.py
SingleAggregateForm
¶
Bases: AliasedForm
SingleAggregateForm assumes that the fusion strategy has already been optimized for this query. There are three valid kinds of input query: 1) transpose queries Query(Table(, output_order), Table(, )) 2) aggregate queries Query(Table(, output_order), Aggregate(_, init, arg, )) (init is a 0-D expression without aggregates or reorders.) 3) in-place queries QueryInto(Table(, output_order), op, arg) (Here, arg has no aggregates. The fields of arg which are not in output_order are reduced with op.)