Adds Serializer and virtual functions for new transform inits#3019
Conversation
…new transform_inits() function added to model
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
…4.1 (tags/RELEASE_600/final)
bbbales2
left a comment
There was a problem hiding this comment.
I like the serializer and updated the tests a bit. That part is good.
I left a Q about one of the transform inits.
It seems we're getting warnings in upstream tests about this too that are causing Jenkins to reject this:
'transform_inits' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] void transform_inits(const io::var_context& context, ^ src/test/test-models/transformed_data_rng_test.hpp:37:54: note: in instantiation of template class 'stan::model::model_base_crtp' requested here class transformed_data_rng_test_model final : public model_base_crtp { ^
| } | ||
|
|
||
| void transform_inits(const io::var_context& context, | ||
| Eigen::VectorXd& params_r, std::ostream* msgs) const { |
There was a problem hiding this comment.
Doesn't this version of the function already exist? I can see why the signature below would be new but I do not understand this one
There was a problem hiding this comment.
Oddly I'm not seeing it in model_base_crtp but am seeing it in model_base. I think it just needs an override keyword and we'll miss this
|
@bbbales2 I thought we could just add the new signature in this PR but I think the steps here are
|
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
|
Aight @bbbales2 I think this is good to go! |
|
Are there examples of what the new stanc3 code should look like using this? Just a note from another thread - we can't change the |
Submission Checklist
./runTests.py src/test/unitmake cpplintSummary
This adds a
stan::io::serializerclass that reads in objects and writes them to a linear array of data. This will be used in the newtransform_inits()signature for the model class to serialize the unconstrained parameters.The only function here is
.write()which accepts any Stan type and writes that to the internal reference to a linear vector.The new transform inits signature is of the form
Where
input_ris the input parameters values andparams_ris an input/output vector of the unconstrained parameters valuesThe new transform inits will use these classes by wrapping
input_rintostan::io::deserializerandparams_rintostan::io::serializer, where it can perform the unconstrain asWhere
Jis the size of the array andN,Mare the dimensions of the matrix.Intended Effect
Along with #3018 this will cleanup a lot of the code generated by the Stan compiler
How to Verify
Tests can be run with
These test all the basic types, arrays of those basic types, and
var_value<>types with inner values of the basic typesSide Effects
None
Documentation
Documentation is written for the new class and for each method in the class.
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Steve Bronder
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: Ste