Finch Logic (High-Level IR)

Finch Logic is an internal high-level intermediate representation (IR) that allows us to fuse and optimize successive calls to array operations such as map, reduce, and broadcast. It is reminiscent to database query notation, representing the a sequence of tensor expressions bound to variables. Values in the program are tensors, with named indices. The order of indices is semantically meaningful.

The nodes are as follows:

Finch.FinchLogic.mapjoinConstant
mapjoin(op, args...)

Logical AST expression for mapping the function op across args.... The order of fields in the mapjoin is unique(vcat(map(getfields, args)...))

source
Finch.FinchLogic.aggregateConstant
aggregate(op, init, arg, idxs...)

Logical AST statement that reduces arg using op, starting with init. idxs are the dimensions to reduce. May happen in any order.

source
Finch.FinchLogic.reorderConstant
reorder(arg, idxs...)

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.

source
Finch.FinchLogic.producesConstant
produces(args...)

Logical AST statement that returns args... from the current plan. Halts execution of the program.

source

Finch Logic Internals

Finch.FinchLogic.LogicNodeType
LogicNode

A Finch Logic IR node. Finch uses a variant of Concrete Field Notation as an intermediate representation.

The LogicNode struct represents many different Finch IR nodes. The nodes are differentiated by a FinchLogic.LogicNodeKind enum.

source
Finch.FinchLogic.logic_leafFunction
logic_leaf(x)

Return a terminal finch node wrapper around x. A convenience function to determine whether x should be understood by default as a immediate or value.

source

Executing FinchLogic