Skip to content
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

WIP: use preproject implementation #457

Closed
wants to merge 3 commits into from
Closed

WIP: use preproject implementation #457

wants to merge 3 commits into from

Conversation

mzgubic
Copy link
Member

@mzgubic mzgubic commented Jun 28, 2021

This is quite ugly since it extracts the relevant information outside the pullback. An extra complication is that

julia> function noinfers(x::AbstractArray)
           T = eltype(x)
           function myclosure()
               return zeros(T, 2, 2)
           end
           return myclosure
       end
noinfers (generic function with 2 methods)

julia> cl = noinfers([1.0, 2.0, 3.0]); @inferred cl()
ERROR: return type Matrix{Float64} does not match inferred return type Matrix{_A} where _A
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ REPL[82]:1

julia> function infers(x::AbstractArray)
           function myclosure()
               return zeros(eltype(x), 2, 2)
           end
           return myclosure
       end
infers (generic function with 2 methods)

julia> cl = infers([1.0, 2.0, 3.0]); @inferred cl()
2×2 Matrix{Float64}:
 0.0  0.0
 0.0  0.0

to which @mcabbott suggested the _val solution on Slack. (without seeing the use case, so he might know a more elegant solution)

@github-actions github-actions bot added the needs version bump Version needs to be incremented or set to -DEV in Project.toml label Jun 28, 2021
@oxinabox
Copy link
Member

oxinabox commented Jun 29, 2021

The extra complication of closing over eltype(a) being type unstable is JuliaLang/julia#23618 and would be fixed by JuliaLang/julia#40985 (but will have to wait for Julia 1.8 for that, if it is merged)

@mzgubic
Copy link
Member Author

mzgubic commented Jul 26, 2021

close in favour of #459

@mzgubic mzgubic closed this Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs version bump Version needs to be incremented or set to -DEV in Project.toml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants