Update generated transform_inits_impl to directly accept a var_context.#1305
Merged
Conversation
…y, add unconstrain_array with old signature
nhuurre
reviewed
Apr 6, 2023
nhuurre
reviewed
Apr 6, 2023
SteveBronder
approved these changes
Apr 6, 2023
Contributor
SteveBronder
left a comment
There was a problem hiding this comment.
Nice, much cleaner! Code and gen'd c++ look good
This was referenced Apr 7, 2023
This was referenced Apr 24, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Submission Checklist
Release notes
Closes #1304.
This PR does a couple things:
Re-using the code gen we already have for the constructor,
transform_inits_implnow takes in a var_context directly. This is what fixes [BUG]transform_initscode for complex numbers is incorrect. #1304, and also will help out with Add tuples to the language #1100. The previous behavior of flattening it down to a flat vector was hacky, and for complex numbers or tuples, wrong.Adds a new function called
unconstrain_arraywhich looks much more like the formertransform_inits. This is the twin ofwrite_arrayand can be eventually exposed/used in place of a lot of the places we're creating aarray_var_context. The idea for a signature like this dates back to when the deserializer was added: Add deserializer class for reading constraints easier stan#3013 (comment). I added this here to keep the existing code fortransform_inits_implaround rather than deleting it and re-coding it later, but it will currently be unused.The second item was actually my original goal, but while working on it I uncovered #1304. The first nicely kills two birds with one stone, fixing that issue and helping out with something I had been stuck on in the tuples PR.
This was able to be done mostly by re-using code already in the compiler. Unfortunately, since the reading code is all generated in
Transform_mirrather than lower down, the simplest solution was to add another (empty until the backend) item to the MIR.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)