EnzymeAD/Enzyme.jl

enzyme_sparse_accumulate and co in Julia

Open

#1,947 opened on Oct 9, 2024

 (0 comments) (0 reactions) (0 assignees)Julia (96 forks)batch import
help wanted

Repository metrics

Stars
 (563 stars)
PR merge metrics
 (Avg merge 5d 1h) (76 merged PRs in 30d)

Description

What would we need to do to define support for sparse operations/jacobians in Enzyme.jl?

using Enzyme
using SparseArrays

julia> Enzyme.jacobian(Enzyme.Forward, x->sum(abs2, x, dims=2), sprandn(12, 0.5))
12×12 Matrix{Float64}:
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
 -1.88261  -1.88261   0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0      -3.04331  0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      1.2327  1.2327  1.2327  1.2327  0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     1.63961  0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0
  0.0       0.0       0.0      0.0     0.0     0.0     0.0     0.0      0.0  0.0  0.0  0.0

Contributor guide