-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Make varmat
functions work with ldlt (Issue #2101)
#2266
Conversation
…4.1 (tags/RELEASE_600/final)
…feature/varmat-ldlt2
…4.1 (tags/RELEASE_600/final)
@@ -64,8 +55,8 @@ TEST(mathMixMatFun, traceGenInvQuadForm) { | |||
|
|||
// exception tests | |||
// non-square second arg | |||
Eigen::MatrixXd a34(3, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't take an LDLT of a non-square matrix, so this fails before it gets to trace_gen_inv_quad_form_ldlt
(which takes an LDLT as an argument)
I ended up replacing the ldlt autodiff that was there, but it's still not great. There new If we're gonna have LDLT factors as autodiff variables, they need to be Still need add a three argument Will also get some benchmarks to make sure the |
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…feature/varmat-ldlt2
…4.1 (tags/RELEASE_600/final)
…feature/varmat-ldlt2
…4.1 (tags/RELEASE_600/final)
Here's benchmarks: And here's the timing results of the one where performance gets bad. Not sure what happened there. I didn't spend time looking into it: Edit: Benchmark code is basically the stuff here and here running with matvars. I had to modify them a bit for the new thing (to use |
…feature/varmat-ldlt2
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
This needs #2280 in before it is ready to go (there's a three argument function in this) |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@SteveBronder is is ready to review now that the three argument tests are in. |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So reviewing this I didn't like that we had to make multiple copies as we passed around the ldlt factor. Trying to sort this out I think it was just easier to make a little review branch with some changes
There's only one thing I strongly don't like about the changes I made which is the forward deceleration of make_chainable_ptr()
in prim. We could flip this around and just declare the method for chainable_ldlt_ptr()
in prim
// in prim's LDLT_factor
inline auto* chainable_ldlt_ptr();
and then in rev
actually define chainable_ldlt_ptr()
for the prim version.
Though if you don't like what I have above then I think then you can ignore that and just use the other review comments
return A.ldlt().solve( | ||
Eigen::Matrix<return_type_t<T, EigMat>, EigMat::RowsAtCompileTime, | ||
EigMat::ColsAtCompileTime>(b)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional] if b
is an rvalue forwarding could be better here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'm gonna leave it as is though. This is some weird type promotion thing so the Eigen solves work. Like if T
and EigMat
don't match, it will make them match.
If we added another overload for when the scalar types are the same it would handle this. I grepped for where this function is used (it's an internal function not exposed to the Stan langage) and I don't think it's actually used anywhere (mdivide_right_ldlt
uses this, but that is unused, and again that is an internal function), so I'm not gonna worry about this (though it would take about 5s to implement -- just seems like more code and complexity some future person has to decode).
Changes look good. I'll merge tomorrow. The |
I moved This is the grep, and
|
@SteveBronder should be ready for review again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@rok-cesnovar this was approved but then my test restart commit dismissed the review. Can you approve and merge? |
Summary
Second attempt at making
varmat
work with ldltSide Effects
I removed
LDLT_alloc
and replacedLDLT_factor
with an API incompatible replacement.So this is a major version bump for Math right?
Release notes
varmat
implementation of*_ldlt_*
functionsChecklist
Math issue Make functions with custom autodiff
var<mat>
friendly #2101Copyright holder: Columbia University
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested