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

Error using autodiff_thunk #791

Closed
sethaxen opened this issue Apr 27, 2023 · 1 comment
Closed

Error using autodiff_thunk #791

sethaxen opened this issue Apr 27, 2023 · 1 comment

Comments

@sethaxen
Copy link
Collaborator

Using autodiff_thunk on sum with a Const return activity results in an AssertionError:

x = [1.1, 2.2]
∂x = zero(x)

fwd, rev = autodiff_thunk(ReverseSplitWithPrimal, Const{typeof(sum)}, Active, Duplicated{typeof(x)});
tape, result, shadow_result = fwd(Const(sum), Duplicated(x, ∂x));
rev(Const(sum), Duplicated(x, ∂x), 1.0, tape)  # fine

fwd, rev = autodiff_thunk(ReverseSplitWithPrimal, Const{typeof(sum)}, Const, Duplicated{typeof(x)});
tape, result, shadow_result = fwd(Const(sum), Duplicated(x, ∂x));
rev(Const(sum), Duplicated(x, ∂x), 1.0, tape)  # error, see below
ERROR: AssertionError: length(argtypes) + needs_tape == length(argexprs)
Stacktrace:
 [1] #s295#184
   @ ~/projects/Enzyme.jl/src/compiler.jl:8357 [inlined]
 [2] var"#s295#184"(RawCall::Any, FA::Any, T::Any, RT::Any, TapeType::Any, N::Any, CC::Any, width::Any, returnPrimal::Any, ::Any, #unused#::Type, fptr::Any, #unused#::Type, #unused#::Type, #unused#::Type, tt::Any, rt::Any, fn::Any, #unused#::Any, args::Any)
   @ Enzyme.Compiler ./none:0
 [3] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
   @ Core ./boot.jl:602
 [4] (::Enzyme.Compiler.AdjointThunk{Const{typeof(sum)}, Const{Float64}, Tuple{Duplicated{Vector{Float64}}}, Val{1}, Nothing})(::Const{typeof(sum)}, ::Duplicated{Vector{Float64}}, ::Vararg{Any})
   @ Enzyme.Compiler ~/projects/Enzyme.jl/src/compiler.jl:8308
 [5] top-level scope
   @ REPL[44]:1
@wsmoses
Copy link
Member

wsmoses commented Apr 27, 2023

You still pass the active return 1.0 in the second case, where you have the return marked as const.

@wsmoses wsmoses closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2023
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

No branches or pull requests

2 participants