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
Adolc tensor refactor #14205
Adolc tensor refactor #14205
Conversation
e7d8ebc
to
8c8bfb4
Compare
This works correctly with advanced branching.
This test should always pass now, regardless of how adol-c is set up.
8c8bfb4
to
efe392b
Compare
for (unsigned int i = 0; i < dim; ++i) | ||
sum += std::fabs(t[i][j]); | ||
|
||
condassign(max, (sum > max), sum, max); |
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.
@drwells For these taped types, one needs to use the condassign()
function to switch between branches. An if
statement won't work if the evaluation point changes which branch is taken.
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'll write a test so that I understand this better.
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 had the ADOL-C manual in hand when decomposing and writing these functions, so whenever you come across an unusual implementation then I'd suggest consulting the manual. The requirements of the taping algorithm often dictates how code with branches has to be written in order to be taped AD compatible. It would not surprise me if there is not a test for every single specialised function -- the implementation was probably "best effort".
Thanks for working towards optimising all things related to the AD types, @drwells. I'll do my best to give you feedback for both this and your other PRs on the weekend. |
These functions really need to be in the header for reasons stated above (condassign in a template function). Furthermore, we don't gain a lot by trying to excise adolc from this file: adolc itself, when installed, only has 6k total lines of header files. Hence lets close this. |
More progress on #13949 - now for adol-c instead of Sacado.
I tested this on my machine with and without advanced branching.