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

Captured x breaks autodiff #205

Closed
vchuravy opened this issue Jan 31, 2022 · 4 comments · Fixed by #408
Closed

Captured x breaks autodiff #205

vchuravy opened this issue Jan 31, 2022 · 4 comments · Fixed by #408

Comments

@vchuravy
Copy link
Member

 let 
        function loadsin(xp)
            x = @inbounds xp[1]
            @inbounds xp[1] = 0.0
            sin(x)
        end
        global invsin
        function invsin(xp)
            xp = Base.invokelatest(convert, Vector{Float64}, xp)
            loadsin(xp)
        end
        x = [2.0]
    end
    x = [2.0]
    dx = [0.0]
    Enzyme.autodiff(invsin, Active, Duplicated(x, dx))
@wsmoses
Copy link
Member

wsmoses commented Aug 6, 2022

The particular bug:

ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] unsafe_convert
   @ ~/.julia/packages/Enzyme/di3zM/src/compiler.jl:4277 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/Enzyme/di3zM/src/compiler.jl:4520 [inlined]
 [3] enzyme_call
   @ ~/.julia/packages/Enzyme/di3zM/src/compiler.jl:4316 [inlined]
 [4] AugmentedForwardThunk
   @ ~/.julia/packages/Enzyme/di3zM/src/compiler.jl:4307 [inlined]
 [5] autodiff
   @ ~/.julia/packages/Enzyme/di3zM/src/Enzyme.jl:272 [inlined]
 [6] autodiff(f::typeof(invsin), #unused#::Type{Active}, args::Duplicated{Vector{Float64}})
   @ Enzyme ~/.julia/packages/Enzyme/di3zM/src/Enzyme.jl:411
 [7] top-level scope
   @ REPL[74]:1

@wsmoses
Copy link
Member

wsmoses commented Aug 8, 2022

Present duplicate of #293

@vchuravy
Copy link
Member Author

vchuravy commented Aug 19, 2022

Fixed by #408

@vchuravy vchuravy linked a pull request Aug 19, 2022 that will close this issue
vchuravy added a commit that referenced this issue Aug 19, 2022
@vchuravy
Copy link
Member Author

On 1.6:

truct return: Error During Test at /home/runner/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:257
  Test threw exception
  Expression: Enzyme.autodiff(invsin, Active, Duplicated(x, dx)) == ()
  TypeError: in typeassert, expected Enzyme.Compiler.Tape, got a value of type Tuple{Core.Compiler.Pair{Core.Compiler.Pair{Int64, Int64}, Any}, Tuple{Int64, Int64}}
Struct return: Test Failed at /home/runner/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:258
  Expression: dx[1] == -0.4161468365471424
   Evaluated: 0.0 == -0.4161468365471424
Stacktrace:
 [1] macro expansion
   @ ~/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:258 [inlined]
 [2] macro expansion
   @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
 [3] top-level scope
   @ ~/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:255
Test Summary: | Fail  Error  Total
Struct return |    1      1      2

@vchuravy vchuravy reopened this Aug 19, 2022
vchuravy added a commit that referenced this issue Sep 5, 2022
wsmoses pushed a commit that referenced this issue Oct 6, 2022
vchuravy added a commit that referenced this issue Oct 6, 2022
@wsmoses wsmoses closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants