stripe / rainier

Bayesian inference in Scala.
https://rainier.fit
Apache License 2.0
432 stars 51 forks source link

Inline based on static analysis #434

Closed avibryant closed 4 years ago

avibryant commented 4 years ago

The major new thing here is RealOps.inlinable which walks the DAG to determine if there are any sub-graphs which a) contain at least one parameter b) contain at least one placeholder and c) have as their root node a non-linear operation like log, exp, pow, etc.

If there are not any such sub-graphs, then it should be possible to simplify the sum across all N placeholder rows to a single O(1) function of the parameters. If any such subgraphs do exist, then we need to keep it in placeholder form and do the N independent evaluations.

This PR also tweaks PartialEvaluator to be specifically for inlining placeholder values (and removes that recently-introduced capability from Evaluator).