-
-
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
Reverse mode autodiff for diag_post_multiply #2453
Conversation
…4.1 (tags/RELEASE_600/final)
@gregorp90 I pushed a fix for an OpenCL test issue that surfaced here. |
@rok-cesnovar Thank you! |
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.
Looks good, just one question.
template <typename T1, typename T2, require_eigen_t<T1>* = nullptr, | ||
require_eigen_vector_t<T2>* = nullptr> | ||
template <typename T1, typename T2, | ||
require_eigen_matrix_dynamic_t<T1>* = nullptr, |
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.
Why the change to this require to not allow vectors?
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.
As far as I can see this is what required the change to OpenCL tests (although new test is fine as well).
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.
I see, so this should be require_eigen_t
instead of require_eigen_matrix_dynamic_t
?
I based this implementation on the implementation of diag_pre_multiply
. In that implementation, Ben made this change, as you can see here. Maybe @bbbales2 can provide some more details on this change?
Also, if we are already on this subject. Why does the prim test with 1x1 matrix not fail, if we have require_eigen_matrix_dynamic_t
?
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.
Yeah require_eigen_t
or require_eigen_matrix_t
is fine.
Also, if we are already on this subject. Why does the prim test with 1x1 matrix not fail, if we have require_eigen_matrix_dynamic_t?
It is not the shape of the input that is the issue, but type. We have general matrix type (that can also contain a vector) and special types for row or column vector. The new require does not accept the specialized vector types, while the test probably uses general matrix type.
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 should I revert back to require_eigen_t
or leave the implementation as it is?
Thanks for the answer, makes things more clear now!
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.
I think you should revert.
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.
OK.
Should I make the same changes for diag_pre_multiply
?
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.
@t4c1 I made the changes to both, diag_pre_multiply
and diag_post_multiply
.
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
Implemented custom reverse mode AD for
diag_post_multiply()
function. The implementation is based on the reverse mode implementation ofdiag_pre_multiply()
.Tests
Added a test for prim where the arguments are of length zero.
Removed manual
ad_tolerances
from the mix test, similar todiag_pre_multiply()
. Also added 4 mix tests, where the matrix is non-square.Side Effects
None.
Release notes
Added custom reverse mode for diag_post_multiply() function.
Checklist
Math issue Functions in prim/mat/fun that could use custom reverse mode autodiff implementations #989
Copyright holder: Gregor Pirš