-
Notifications
You must be signed in to change notification settings - Fork 149
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
inference problem with broadcasting and / #682
Comments
And f(η, B, R, 𝑢, σ, C) = (η .* (B .- R) / 𝑢 .- C) ./ σ (note |
Thanks for the report. I do wonder whether there's anything we can realistically do about this, or whether a fix is required in Base. I guess a deep dive will be required to figure out what's going on. |
I tried to investigate but could not figure it out, I was kind of hoping that someone here with more knowledge about debugging these issues would take it up. |
Understood. I haven't had time to do the requisite digging and TBH Julia's type inference implementation is not something I know a lot about yet. Any thoughts @martinholters? You've solved a few of these type of problems before :-) |
This might be related to #609 and JuliaLang/julia#32552 (and linked history within) -- this is definitely my biggest gripe with julia, that it's essentially impossible to write high performance code combining | | |_| | | | (_| | | Version 1.3.0-rc4.1 (2019-10-15)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using ForwardDiff, StaticArrays, Test
julia> begin
_dual(x) = ForwardDiff.Dual(x, 1 + x) # for testing
broadcasted_division(x, y) = x ./ y
f(η, B, R, 𝑢, σ, C) = (η .* broadcasted_division(B .- R, 𝑢) .- C) ./ σ
A = fill(1.0, SMatrix{2, 2})
b = 1.0
end
1.0
julia> @inferred f(A, b, A, b, b, A) # infers fine
2×2 SArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
-1.0 -1.0
-1.0 -1.0
julia> @inferred f(A, b, A, _dual(b), b, A) # now also infers fine
2×2 SArray{Tuple{2,2},ForwardDiff.Dual{Nothing,Float64,1},2,4} with indices SOneTo(2)×SOneTo(2):
Dual{Nothing}(-1.0,-0.0) Dual{Nothing}(-1.0,-0.0)
Dual{Nothing}(-1.0,-0.0) Dual{Nothing}(-1.0,-0.0)
(v1.3) pkg> st
Status `~/.julia/environments/v1.3/Project.toml`
[f6369f11] ForwardDiff v0.10.6
[90137ffa] StaticArrays v0.12.1 #master (https://github.com/JuliaArrays/StaticArrays.jl.git) |
adds a summary of issues discussed in JuliaArrays#682 and JuliaArrays#560 to the documentation
Small update: I've proposed a solution here: JuliaLang/julia#41090 . |
This is an MWE isolated from a larger piece of code:
Version information:
The text was updated successfully, but these errors were encountered: