Stan math should have specific type traits only the compiler uses
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 160
- Forks
- 59
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 26
Description
#1709 is a PR that turns on SoA for math function signatures like vector fma(var, data vector, var). It does this by calling rep_vector on one of the var members of the signature. This creates a size(data vector) SoA matrix in the signature. This is not terrible, but not great either.
I think we should have Stan compiler specific tags and type traits the compiler can use to sneakily tell Stan math things. For instance, we can have a type trait that is just a no-op wrapper around vars to tell stan math to promote the end result to a SoA matrix. So the end C++ we generate would look something like
var_value<Eigen::VectorXd> d = fma(stanc_promote_soa{a_var}, b_vec, stanc_promote_soa{c_var})
stanc_promote_soa would be a minimal class that just holds a reference to a var and tell the stan math type traits that the end result should be a SoA matrix.
This would be a much more efficient impl
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with PR #1709 and the existing rep_vector use described in the issue, then trace how the compiler generates signatures such as fma(var, data vector, var). Done means defining compiler-specific promotion traits and generating the proposed wrapper-based C++ form, with the resulting Stan Math type behavior verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, ocaml
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100