In fact, such a data structure is already used in the code generation (for a subset of languages). It would be cleaner system design to have it as the fundamental graph structure.
Reason: It would eliminate the need for a DegOpt data structure. With this change a DegOpt would be a particular case of this data structure. In the future I want to generalize the DegOpts and this would be helpful to do first.
Cons:
Quite a bit refactorization needed. Changes in code generation, storage, as well as gradient factorization.
Slightly more complicated gradient computation (and evaluation?)
Pros:
Some code can be removed, including reduction of special case code for DegOpt in code generation.
The new data structure would generalize the old data structure, so there would be no breaking changes for users and tests should still pass.
Cleaner generated code, since e.g., matlab could do the entire sum with one line.
Our original thought was that there were data structure advantages that every node has exactly two parents. I'm not so convinced anymore.
Currently the graph data structures allows for linear combination:
a1*A1+a2*A2
Instead I suggest we allow for:
a1*A1+... +aN*AN
(in floating point interpreted as evaluation as usual from left to right).The main data structure change would involve changing
Tuple
toNTuple
orVector
or similar on line 46-47:https://github.com/matrixfunctions/GraphMatFun.jl/blob/dc7e01d4dbcec7a19275d15c242b65aa1497881c/src/compgraph_struct.jl#L43-L50
In fact, such a data structure is already used in the code generation (for a subset of languages). It would be cleaner system design to have it as the fundamental graph structure.
https://github.com/matrixfunctions/GraphMatFun.jl/blob/dc7e01d4dbcec7a19275d15c242b65aa1497881c/src/code_gen/multilincomb.jl#L3-L10
Reason: It would eliminate the need for a
DegOpt
data structure. With this change aDegOpt
would be a particular case of this data structure. In the future I want to generalize the DegOpts and this would be helpful to do first.Cons:
Pros:
Our original thought was that there were data structure advantages that every node has exactly two parents. I'm not so convinced anymore.