Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Example integration with DI #10

Closed
gdalle opened this issue Apr 9, 2024 · 1 comment
Closed

Example integration with DI #10

gdalle opened this issue Apr 9, 2024 · 1 comment

Comments

@gdalle
Copy link
Collaborator

gdalle commented Apr 9, 2024

Setup

using Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/SciML/ADTypes.jl", rev="gd/sparsity_detector")
Pkg.add(url="https://github.com/gdalle/DifferentiationInterface.jl", subdir="DifferentiationInterface", rev="gd/sparsity_detector")
Pkg.add(url="https://github.com/gdalle/DifferentiationInterface.jl", subdir="DifferentiationInterfaceTest")
Pkg.add(url="https://github.com/gdalle/SparseConnectivityTracer.jl", rev="main")
Pkg.add(["BenchmarkTools", "ForwardDiff", "SparseDiffTools", "Symbolics"])

using BenchmarkTools
using DifferentiationInterface
import ForwardDiff, SparseConnectivityTracer, SparseDiffTools, Symbolics

b1 = AutoSparseForwardDiff(; sparsity_detector=SparseDiffTools.SymbolicsSparsityDetection())

b2 = AutoSparseForwardDiff(;
    sparsity_detector=Base.get_extension(
        SparseConnectivityTracer,
        :SparseConnectivityTracerSparseDiffToolsExt
    ).ConnectivityTracerSparsityDetection()
)

Results:

julia> @btime prepare_jacobian($diff, $b1, $(rand(100)));
  1.271 ms (15662 allocations: 1.10 MiB)

julia> @btime prepare_jacobian($diff, $b2, $(rand(100)));
  84.229 μs (1964 allocations: 213.94 KiB)
@gdalle
Copy link
Collaborator Author

gdalle commented Apr 9, 2024

This relies on #9

Repository owner locked and limited conversation to collaborators Apr 10, 2024
@adrhill adrhill converted this issue into discussion #15 Apr 10, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant