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.immediate — Constant
immediate(val)Logical AST expression for the literal value val.
Finch.FinchLogic.deferred — Constant
deferred(ex, [type])Logical AST expression for an expression ex of type type, yet to be evaluated.
Finch.FinchLogic.field — Constant
field(name)Logical AST expression for an field named name.
Finch.FinchLogic.alias — Constant
alias(name)Logical AST expression for an alias named name.
Finch.FinchLogic.table — Constant
table(tns, idxs...)Logical AST expression for a tensor object tns, indexed by fields idxs....
Finch.FinchLogic.mapjoin — Constant
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)...)) Dimensions of fields from different arguments must match, and fields which are missing from an argument are broadcasted.
Finch.FinchLogic.aggregate — Constant
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.
Finch.FinchLogic.reorder — Constant
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, also with length 1.
Finch.FinchLogic.relabel — Constant
relabel(arg, idxs...)Logical AST statement that relabels the dimensions of arg to be idxs...
Finch.FinchLogic.reformat — Constant
reformat(tns, arg)Logical AST statement that reformats arg into the tensor tns.
Finch.FinchLogic.subquery — Constant
subquery(lhs, arg)Logical AST statement that evaluates arg, binding the result to lhs, and returns arg.
Finch.FinchLogic.query — Constant
query(lhs, rhs)Logical AST statement that evaluates rhs, binding the result to lhs.
Finch.FinchLogic.produces — Constant
produces(args...)Logical AST statement that returns args... from the current plan. Halts execution of the program.
Finch.FinchLogic.plan — Constant
plan(bodies...)Logical AST statement that executes a sequence of statements bodies....
Finch Logic Internals
Finch.FinchLogic.LogicNode — Type
LogicNodeA 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.
Finch.FinchLogic.logic_leaf — Function
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.
Finch.FinchLogic.isimmediate — Function
isimmediate(node)Returns true if the node is a finch immediate
Finch.FinchLogic.isdeferred — Function
isdeferred(node)Returns true if the node is a finch immediate
Finch.FinchLogic.isalias — Function
isalias(node)Returns true if the node is a finch alias
Finch.FinchLogic.isfield — Function
isfield(node)Returns true if the node is a finch field