Refactor/variadic codegen cleanups #1262
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: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.pstream
argument get passed to thef
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 functionf
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
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)