Skip to content

StackOverflow in forward mode #1330

Closed as not planned
Closed as not planned
@gdalle

Description

@gdalle
julia> using Enzyme

julia> g(x::Number) = [sin(x) cos(x); sin(2x) cos(2x)]
g (generic function with 1 method)

julia> autodiff(Forward, g, Duplicated, Duplicated(1.0, 1.0))
ERROR: StackOverflowError:
Stacktrace:
     [1] hvcat
       @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1269 [inlined]
     [2] hvcat
       @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:0 [inlined]
     [3] fwddiffejulia_hvcat_6909_inner_1wrap
       @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:0
     [4] macro expansion
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5378 [inlined]
     [5] enzyme_call
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5056 [inlined]
     [6] ForwardModeThunk
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5001 [inlined]
     [7] runtime_generic_fwd(activity::Type{…}, width::Val{…}, RT::Val{…}, f::typeof(hvcat), df::Nothing, primal_1::Tuple{…}, shadow_1_1::Nothing, primal_2::Float64, shadow_2_1::Float64, primal_3::Float64, shadow_3_1::Float64, primal_4::Float64, shadow_4_1::Float64, primal_5::Float64, shadow_5_1::Float64)
       @ Enzyme.Compiler ~/.julia/packages/Enzyme/wR2t7/src/rules/jitrules.jl:116
--- the last 7 lines are repeated 5630 more times ---
 [39418] hvcat
       @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1269 [inlined]
 [39419] g
       @ ~/Work/GitHub/Julia/DifferentiationInterface.jl/test/enzyme.jl:18 [inlined]
 [39420] fwddiffejulia_g_9702wrap
       @ ~/Work/GitHub/Julia/DifferentiationInterface.jl/test/enzyme.jl:0
 [39421] macro expansion
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5378 [inlined]
 [39422] enzyme_call
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5056 [inlined]
 [39423] ForwardModeThunk
       @ ~/.julia/packages/Enzyme/wR2t7/src/compiler.jl:5001 [inlined]
 [39424] autodiff(::ForwardMode{FFIABI}, f::Const{typeof(g)}, ::Type{Duplicated}, args::Duplicated{Float64})
       @ Enzyme ~/.julia/packages/Enzyme/wR2t7/src/Enzyme.jl:324
 [39425] autodiff(::ForwardMode{FFIABI}, ::typeof(g), ::Type, ::Duplicated{Float64})
       @ Enzyme ~/.julia/packages/Enzyme/wR2t7/src/Enzyme.jl:224
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions