Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/variadic codegen cleanups #1262

Merged
merged 7 commits into from
Oct 24, 2022

Conversation

WardBrian
Copy link
Member

This is a follow on to #1259 which tries to do a similar amount of clean-up to the backend code generation. Once again, we treat reduce_sum as a special case still, but the other variadic HOFs share the same structure except for two details, which differ per signature:

  1. Where does the pstream argument go in the call to the higher order function, e.g. dae(f, ..., msgs, ...). This differs between each function and its _tol version.
  2. Where does the pstream argument get passed to the f in the above call? For DAEs, this is 4, for ODEs 3, etc. Another way of saying this is how many non-variadic arguments does the function f get called with in C++.

By adding this tiny bit of backend-specific data to the variadic signature table added in #1259 the code generation gets much nicer and cares a lot less about the specifics of Stan_math_signatures. If someone wants to build a non-C++ backend, they can just ignore these or set them to 0 for new signatures.

Changes to the test output only occurred because this change means that the names of the functors generated changed slightly, now it is based on the number specified in bullet 2 above rather than the name, so _odefunctor_ becomes _vari_3_functor_

Submission Checklist

  • Run unit tests
  • Documentation
    • If a user-facing facing change was made, the documentation PR is here:
    • OR, no user-facing changes were made

Release notes

Replace this text with a short note on what will change if this pull request is merged. This will be included in the release notes.

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

src/middle/Stan_math_signatures.mli Outdated Show resolved Hide resolved
src/stan_math_backend/Expression_gen.ml Outdated Show resolved Hide resolved
@WardBrian WardBrian requested a review from nhuurre October 24, 2022 18:56
@WardBrian WardBrian merged commit 7d221fe into master Oct 24, 2022
@WardBrian WardBrian deleted the refactor/variadic-codegen-cleanups branch October 24, 2022 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants