Skip to content

Hvcat stackoverflow #1653

@dleather

Description

@dleather

I'm running Enzyme 0.12.23, EnzymeCore 0.7.7, Linear Algebra 1.5.0, Sparse Arrays 1.10.0 in Julia 1.10.4 on a Windows machine. Without fail Enzyme crashes. I can get Zygote to differentiate the function quickly. I've tried replacing all calls to I() with there explicit matrix form, as well as making Λ non-sparse.

using Enzyme, SparseArrays, LinearAlgebra

function compute_L1(Σ::Matrix{T}, Λ::AbstractSparseMatrix{T}) where T <: Real
    # LHS coefficient from Proposition 3.2
    #   L₁ = [Σ ⊗ (Iₙ² + Λₙ)] ⊗ [vec(Iₙ) ⊗ Iₙ]
    N = size(Σ, 1)
    return kron(Σ, I + Λ) * kron(vec(I(N)), I(N))
end

Λ =  spzeros(4, 4)
Λ[1, 1] = 1.0
Λ[3, 2] = 1.0
Λ[2, 3] = 1.0
Λ[4, 4] = 1.0

Δt = 0.25

function f(θ)
    σ_z = θ[1]
    θ_z = θ[2]
    Ω = [sqrt(((σ_z^2)/(2.0 * θ_z))*(1-exp(-2*θ_z*Δt))) 0.0; 0.0 0.0]
    Σ = Ω * Ω'
    L1 = compute_L1(Σ, Λ)
    return L1[1]
end

θ = [1.0, 0.5]
dθ = similar(θ)
f(θ)
Enzyme.autodiff(Reverse, f, Active, Duplicated(θ, dθ))

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