-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Fix accidental precision loss (#814) #817
Conversation
There's accidental precision loss due to the use of integer instead of floating point divide. The function also does redundant loads and possibly a redundant divide, even with optimization enabled. See stan-dev#814 for more details and discussion.
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.
Thanks.
We can come back and clean up the potential catastrophic arithmetic and raw calls to alloc in another pass.
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.
This should get a test that fails in the previous release and passes now. We want to try to stop regressions on these things. This function was presumably missing good tests or we would've caught that case.
@bob-carpenter Where should the test live in the test hierarchy? I don't think I understand the directory structure. |
Oh wait, I see that there's |
Yes, that's where the gradient test for vector and row vector inputs should go for now. @seantalts is going to collapse the |
@danluu I can finish up this pull request if you don't have time. This looks good and we should get it in. This is test code that fails with the current implementation, but works in the new one (I basically wrote up the example in the issue #814). It should go in test/unit/math/rev/mat/fun/variance_test.cpp
|
Sorry, got really busy recently. I certainly don't mind finishing it, but I'm not sure when I'd get around to it. If you want to finish it up, please go ahead :-). |
@danluu Hahaha, it worked! I saw @seantalts do this, but apparently since I have permissions on this repo, I also get free permissions on your fork! So I merged in the new develop and added a test to your branch. That probably violates all forms of repo etiquette. I probably should have asked first haha. |
…stable/2017-11-14)
@bob-carpenter Test added, and I merged in the latest develop. This should be good to go |
Submission Checklist
./runTests.py test/unit
make cpplint
Summary:
There's accidental precision loss due to the use of integer instead of floating point divide. The offending function also does redundant loads and possibly a redundant divide, even with optimizations enabled. See #814 for more details and discussion.
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):
Dan Luu
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: