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
Halide floating point behavior #3813
Comments
|
Took a stab at resolving this and postulated removing the AllowReassoc flag from the fastmath options here would resolve the issue. Kinda stumped it didn't, any suggestions on where to look next? |
|
Found the cause, the solution is still a little unclear though, |
|
Hrm, it's supposed to be set to true when visiting the strict_float intrinsic in Simplify_Call.cpp |
|
So maybe the bug is that strict_float wasn't injected somewhere it should have been? |
|
yeah just saw that flag as well and it does seem to work, turning up the debug level in the codegen gives me You may be onto something there, it seems to only partially mark the expression as strict float |
|
Maybe CSE is pulling subexpressions out of strict_float incorrectly.
…On Mon, Apr 15, 2019 at 10:03 AM LazyDodo ***@***.***> wrote:
yeah just saw that flag as well and it does seem to work, turning up the
debug level in the codegen gives me
With lets: (let t0 = sin_f32(((float32(y)*78.233002f) + ((float32(x) + 1.000000f)*12.989800f))) in strict_float(((t0*43758.546875f) - floor_f32((t0*43758.546875f)))))
You may be onto something there, it seems to only partially mark the
expression as strict float
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3813 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAfdRtermBZOyxg9w752afpOWBhlIKZYks5vhLD5gaJpZM4csk0l>
.
|
|
Part of the reason for wrapping the strict_float intrinsic around all |
|
I'm going to guess what is happening here is that |
|
You actually had it right in your April 15 post, CSE is losing the strict_float attribute during its substitutions, debugged into it to the point where I could validate your suspicion but have lacked time since to actually sit down and fix it. |
|
Is this being strictified twice? Generating nested strict_floats: |
|
Guess this comment was for #4012 ? The test only applies strict_float once at the very outer level |
|
Oops, yeah. I'll make the comment on that thread instead. |
I'm having issues with a halide being a little too aggressive in it's handling of floating point calculations.
The issue at its core is that halide thinks that transforming
(x+1)*ninto(x*n)+nis a valid thing to do, and while that holds true for integer operations, floating point is less forgiving about this and will introduce small differences in the calculation, nvidia warns about this behavior of floating point math here .Now this issue has come up before in issue #3549 which suggested the use of strict_float which did seem to initially solve the issue, it seems it was just better at masking it.
Even with strict_float applied, halide still seemingly randomly decides to mess with the order of things. I attached a heavily commented repro case in python (pastebin version available here).
Due to its use of strict_float it needs PR #3811 to function so make sure you have a recent build.
noise_cpu.zip
The text was updated successfully, but these errors were encountered: