Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Converting DDC expressions to and from Combinator Normal Form.
- data Fun s a = Fun ExpF [s]
- data Bind s a
- data ABind s a
- data SBind s a = Fold (Fun s a) (Scalar s a) a
- data Scalar s a = Scalar ExpF (Maybe s)
- data Program s a = Program {}
- data CName s a
- = NameScalar s
- | NameArray a
- lookupA :: Eq a => Program s a -> a -> Maybe (ABind s a)
- lookupS :: Eq s => Program s a -> s -> Maybe (SBind s a)
- lookupB :: (Eq s, Eq a) => Program s a -> CName s a -> Maybe (Bind s a)
- envOfBind :: Bind s a -> ([s], [a])
- freeOfBind :: Bind s a -> [CName s a]
- cnameOfBind :: Bind s a -> CName s a
- outputsOfCluster :: (Eq s, Eq a) => Program s a -> [CName s a] -> [CName s a]
- inputsOfCluster :: (Eq s, Eq a) => Program s a -> [CName s a] -> [CName s a]
- seriesInputsOfCluster :: (Eq s, Eq a) => Program s a -> [CName s a] -> [a]
Documentation
Worker function. May only reference scalars in the environment, not arrays. Takes the expression of the function, and a list of the free scalars that are referenced inside it. The expression must be a function from scalar to scalar.
Array, scalar and external bindings. Array bindings are those whose value is an array, such as map, filter. Scalar bindings have scalar values, currently only fold. External expressions are those that cannot be converted to primitive combinators. The they take a single expression that computes all outputs, with the list of free scalar and array inputs.
An array-valued binding.
MapN (Fun s a) [a] | map_n :: (a_1 ... a_n -> b) -> Array a_1 ... Array a_n -> Array b |
Filter (Fun s a) a | filter :: (a -> Bool) -> Array a -> Array a |
Generate (Scalar s a) (Fun s a) | generate :: Nat -> (Nat -> a) -> Array a |
Gather a a | gather :: Array a -> Array Nat -> Array a |
Cross a a | cross :: Array a -> Array b -> Array (a, b) |
A scalar-valued binding
Scalars can either be a literal such as "0", or a named scalar reference. If it's not a named scalar reference, we need to keep the expression so we can reconstruct it later. (We do not have array literals, so this is only necessary for scalars)
An entire program/function to find a fusion clustering for
Name of a combinator. This will also be the name of the corresponding node of the graph.
NameScalar s | |
NameArray a |
freeOfBind :: Bind s a -> [CName s a] Source #
cnameOfBind :: Bind s a -> CName s a Source #
outputsOfCluster :: (Eq s, Eq a) => Program s a -> [CName s a] -> [CName s a] Source #
For a given program and list of nodes that will be clustered together, find a list of the nodes that are used afterwards. Only these nodes must be made manifest. The output nodes is a subset of the input cluster nodes.