You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces the simplification of the tilde-callstack as discussed in #249.
Copy-pasted from there:
- Remove unnecessary complexity in `~` implementation.
- Current calling hierarchy for a `~` statement is:
- `tilde_assume` -> `tilde(rng, ...)` -> `_tilde(rng, ...)` -> `assume`
- `tilde_observe` -> `tilde(...)` -> `_tilde(...)` -> `observe`
- Similarly for `dot_tilde_assume` and `dot_tilde_observe`.
- This is super-confusing and difficult to debug.
- `_tilde` is currently only used for `NamedDist` to allow overriding the variable-name used for a particular `~` statement.
- Propose the following changes:
- Remove `_tilde` and handle `NamedDist` _before_ calling `tilde_assume`, etc. by using a `unpack_right_vns` (and `unpack_right_left_vns` for dot-statements) (thanks to @devmotion)
- Rename `tilde_assume` (`tilde_observe`) and to `tilde_assume!` (`tilde_observe!`), and `tilde(rng, ...)` (`tilde(...)`) to `tilde_assume(rng, ...)` (`tilde_observe(...)`).
- `tilde_assume!` simply calls `tilde_assume` followed by `acclogp(varinfo, result_from_tilde_assume)`, so the `!` here is to indicate that it's mutating the `logp` field in `VarInfo`.
Co-authored-by: Hong Ge <[email protected]>
0 commit comments