Index
Aggregate
dataclass
¶
Bases: LogicTree, LogicExpression
Represents a logical AST statement that reduces arg using op, starting
with init. idxs are the dimensions to reduce. May happen in any order.
init may be a literal or a tensor expression. The fields of the result
are those of arg which are not reduced, followed by the fields of init
which are not in arg. init and arg are broadcast over the fields of
the result which they lack, as in a MapJoin.
Attributes:
| Name | Type | Description |
|---|---|---|
op |
Literal
|
The reduction operation. |
init |
LogicExpression
|
The initial value for the reduction. |
arg |
LogicExpression
|
The argument to reduce. |
idxs |
tuple[Field, ...]
|
The dimensions to reduce. |
Source code in src/finch/finch_logic/nodes.py
Alias
dataclass
¶
Shared base for hard and fused aliases referring to tensors.
Source code in src/finch/finch_logic/nodes.py
BufferizedNDArrayFormatter
¶
Bases: MonoLogicFormatter
Source code in src/finch/autoschedule/formatter/formatter.py
get_tensor_ftype(fill_type, shape_type)
¶
Return the FType of the output tensor produced within the autoscheduler.
Source code in src/finch/autoschedule/formatter/formatter.py
CompilerFormLowerer
¶
Bases: FormattedForm, LogicLoader
Pass a program in FormattedForm to a loader which expects CompilerForm. CompilerForm keeps the definitions and updates of FormattedForm, so the program is unchanged.
Source code in src/finch/autoschedule/compiler.py
CostProtocolizer
¶
Bases: FormattedForm, LogicLoader
Pass a program in FormattedForm to ctx, after choosing the protocol which each table reads each level of its formatted tensor with, as optimize_protocols does under cost_model.
Source code in src/finch/autoschedule/protocolize.py
Field
dataclass
¶
Represents a logical AST expression for a field named name.
Fields are used to name the dimensions of a tensor. The named
tensor is referred to as a "table".
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the field. |
Source code in src/finch/finch_logic/nodes.py
Literal
dataclass
¶
Bases: LogicExpression, LiteralTerm, ExpressionTerm
Represents a logical AST expression for the literal value val.
A literal behaves as a zero-dimensional tensor: it has no fields, and its
element type and fill value are those of val itself.
Attributes:
| Name | Type | Description |
|---|---|---|
val |
T
|
The literal value. |
Source code in src/finch/finch_logic/nodes.py
LogicCompiler
¶
Bases: CompilerForm, LogicLoader
Compile logic using the notation loader's safety mode for shape checks.
Source code in src/finch/autoschedule/compiler.py
LogicEinsumLowerer
¶
Bases: FormattedForm, Stage
Source code in src/finch/autoschedule/stages.py
lower(term, 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
LogicFormatter
¶
Bases: LoopOrderedForm, LogicLoader
Source code in src/finch/autoschedule/stages.py
lower(term, bindings, stats, stats_factory)
abstractmethod
¶
Optimize the tensor formats and output orders for each query.
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
LogicProtocolizer
¶
Bases: FormattedForm, LogicLoader
Pass a program in FormattedForm to ctx, after reading each level of a formatted tensor with an explicit protocol, as protocolize does.
Source code in src/finch/autoschedule/protocolize.py
MapJoin
dataclass
¶
Bases: LogicTree, LogicExpression, CallTerm
Represents a logical AST expression for mapping the function op across args....
Dimensions which are not present are broadcasted. Dimensions which are
present must match. The order of fields in the mapjoin is
unique(vcat(map(getfields, args)...))
Attributes:
| Name | Type | Description |
|---|---|---|
op |
Literal
|
The function to map. |
args |
tuple[LogicExpression, ...]
|
The arguments to map the function across. |
Source code in src/finch/finch_logic/nodes.py
children
property
¶
Returns the children of the node.
Plan
dataclass
¶
Bases: LogicTree, LogicStatement
Represents a logical AST statement that executes a sequence of statements
bodies.... Returns the last statement.
Attributes:
| Name | Type | Description |
|---|---|---|
bodies |
tuple[LogicStatement, ...]
|
The sequence of statements to execute. |
Source code in src/finch/finch_logic/nodes.py
children
property
¶
Returns the children of the node.
infer_dimmap(op, dim_bindings)
¶
Infers dimmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
infer_valmap(f, g, h, bindings)
¶
Infers valmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
PostWalk
¶
A rewriter which recursively rewrites the arguments of each node using
rw, then rewrites the resulting node. If all rewriters return nothing,
returns nothing.
Attributes:
| Name | Type | Description |
|---|---|---|
rw |
RwCallable
|
The rewriter function to apply. |
Source code in src/finch/symbolic/rewriters.py
PreWalk
¶
A rewriter which recursively rewrites each node using rw, then rewrites
the arguments of the resulting node. If all rewriters return nothing,
returns nothing.
Attributes:
| Name | Type | Description |
|---|---|---|
rw |
RwCallable
|
The rewriter function to apply. |
Source code in src/finch/symbolic/rewriters.py
Produces
dataclass
¶
Bases: LogicTree, LogicStatement
Represents a logical AST statement that returns args... from the current plan.
Halts execution of the program.
Attributes:
| Name | Type | Description |
|---|---|---|
args |
tuple[Alias | LogicExpression, ...]
|
The arguments to return. |
Source code in src/finch/finch_logic/nodes.py
children
property
¶
Returns the children of the node.
infer_dimmap(op, dim_bindings)
¶
Infers dimmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
infer_valmap(f, g, h, bindings)
¶
Infers valmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
Query
dataclass
¶
Bases: LogicTree, LogicStatement
Represents a logical AST statement that evaluates rhs, storing the result
in the table lhs. The alias lhs.tns is bound to a tensor whose
dimensions are ordered as lhs.idxs, so a query behaves as though its
right-hand side were wrapped in Reorder(rhs, lhs.idxs). A query is not
in place: the previous value of lhs.tns is replaced, and is only read if
rhs refers to it. See QueryInto for in-place updates.
Attributes:
| Name | Type | Description |
|---|---|---|
lhs |
Table
|
The table to write, a |
rhs |
LogicExpression
|
The right-hand side to evaluate. |
Source code in src/finch/finch_logic/nodes.py
children
property
¶
Returns the children of the node.
infer_dimmap(op, dim_bindings)
¶
Infers dimmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
infer_valmap(f, g, h, bindings)
¶
Infers valmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
QueryInto
dataclass
¶
Bases: LogicTree, LogicStatement
Represents a logical AST statement that updates the table lhs in place,
using the reduction operator op to fold each element of rhs into the
matching element of lhs. The alias lhs.tns must already be bound, and
its shape is preserved. The fields of rhs which are not in lhs.idxs
are reduced with op, and rhs is broadcast over the fields of lhs
which it lacks, so a QueryInto is equivalent to the aggregate which
starts from lhs,
Query(lhs, Aggregate(op, lhs, rhs, setdiff(rhs.fields(), lhs.idxs))).
Attributes:
| Name | Type | Description |
|---|---|---|
lhs |
Table
|
The table to update, a |
op |
Literal
|
The reduction operator used to combine old and new values. |
rhs |
LogicExpression
|
The right-hand side to evaluate. |
Source code in src/finch/finch_logic/nodes.py
children
property
¶
Returns the children of the node.
as_query()
¶
The equivalent aggregate query, which is not in place.
infer_dimmap(op, dim_bindings)
¶
Infers dimmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
infer_valmap(f, g, h, bindings)
¶
Infers valmaps for all aliases defined in the statement. The results will be stored in the dictionary passed to the method.
Source code in src/finch/finch_logic/nodes.py
Relabel
dataclass
¶
Bases: LogicTree, LogicExpression
Represents a logical AST statement that relabels the dimensions of arg to be
idxs.... Number of fields of arg and idxs must match.
Attributes:
| Name | Type | Description |
|---|---|---|
arg |
LogicExpression
|
The argument to relabel. |
idxs |
tuple[Field, ...]
|
The new labels for dimensions. |
Source code in src/finch/finch_logic/nodes.py
Reorder
dataclass
¶
Bases: LogicTree, LogicExpression
Represents a logical AST statement that reorders the dimensions of arg to be
idxs.... Dimensions known to be length 1 may be dropped. Dimensions that do not
exist in arg may be added.
Attributes:
| Name | Type | Description |
|---|---|---|
arg |
LogicExpression
|
The argument to reorder. |
idxs |
tuple[Field, ...]
|
The new order of dimensions. |
Source code in src/finch/finch_logic/nodes.py
SmartFormatter
¶
Bases: LogicFormatter
Source code in src/finch/autoschedule/formatter/smart_formatter.py
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 | |
get_tensor_ftype(fill_type, shape_type, stats, over=())
abstractmethod
¶
The format of a tensor with the given stats. If over lists
fields, each tensor stores one slice which fixes those fields.
Source code in src/finch/autoschedule/formatter/smart_formatter.py
Table
dataclass
¶
Bases: LogicTree, LogicExpression
Represents a logical AST expression for a tensor object tns, indexed by fields
idxs.... A table is a tensor with named dimensions.
Attributes:
| Name | Type | Description |
|---|---|---|
tns |
Literal | Alias
|
The tensor object. |
idxs |
tuple[Field, ...]
|
The fields indexing the tensor. |
protocols |
tuple[Protocol, ...]
|
How a loop visits each field of the table when it reads it, or none to let the tensor choose every protocol. |
Source code in src/finch/finch_logic/nodes.py
Value
dataclass
¶
normalize_names(prgm, bindings)
¶
normalize_names(
prgm: LogicStatement, bindings: dict[Alias, T]
) -> tuple[LogicStatement, dict[Alias, T]]
Normalizes names of aliases and fields in the logic program to avoid conflicts. The fields an aggregate reduces are its own, so they are renamed apart from any field of the same name outside it, unless an enclosing Fuse loops over them.
Source code in src/finch/autoschedule/normalize.py
optimize_protocols(prgm, bindings, stats, stats_factory, cost_model=PROTOCOL_COST_MODEL)
¶
prgm, reading each level with the protocol which costs least under cost_model, as choose_protocols chooses them.