binary5 are binary ops taking 5 arguments (leftVal, rightVal, row, column, overlap) -- these are only applicable for matrix multiplication in a semiring.
All usage of (row, column) above are called as (index, index) for vectors, meaning the code can use either row or column and the meaning will be the same for vectors. It's always just the index position. Passing it twice makes the API simpler.
Operators are also listed by operation. This lets each operation filter what operators make sense. For example, gt makes sense for intersection, but not union.
Thunks are handled by calling populateBinary, followed by code to grab the thunk argument from the block, replace all usages with the thunk, and then removing the argument from the block. This effectively turns it into a unary op, but keeps the definition consistent.
A new pattern has emerged for handling operation-specific custom operators (ex. select with probability). The custom operator must be handled in the non-generic lowering pass. Often, the custom operator affects deeply nested code. To avoid rewriting the outer loop, we write the outer loop(s) in a buildAlgorithm public function which accepts a function as an argument. The custom code is now injected by writing a function and passing it to buildAlgorithm. The generic operation uses the same buildAlgorithm to inject its code. See LowerSelectRewrite for an example of this pattern.
populate
methods for all operations and operatorsOperations:
Some important things to note:
unary1
are unary ops taking one argument (value)unary3
are unary ops taking three arguments (value, row, column)monoid2
are monoid ops taking two arguments (aVal, bVal)binary2
are binary ops taking 2 arguments (leftVal, rightVal)binary4
are binary ops taking 4 arguments (leftVal, rightVal, row, column)binary5
are binary ops taking 5 arguments (leftVal, rightVal, row, column, overlap) -- these are only applicable for matrix multiplication in a semiring.gt
makes sense for intersection, but not union.populateBinary
, followed by code to grab the thunk argument from the block, replace all usages with the thunk, and then removing the argument from the block. This effectively turns it into a unary op, but keeps the definition consistent.buildAlgorithm
public function which accepts a function as an argument. The custom code is now injected by writing a function and passing it tobuildAlgorithm
. The generic operation uses the samebuildAlgorithm
to inject its code. SeeLowerSelectRewrite
for an example of this pattern.