Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FunctionWrappersWrappers"
uuid = "77dc65aa-8811-40c2-897b-53d922fa7daf"
authors = ["Chris Elrod <elrodc@gmail.com> and contributors"]
version = "1.9.0"
version = "1.9.1"

[deps]
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
Expand Down
16 changes: 16 additions & 0 deletions ext/FunctionWrappersWrappersEnzymeExt.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
module FunctionWrappersWrappersEnzymeExt

using FunctionWrappersWrappers
using FunctionWrappersWrappers: SingleCacheStorage, DictCacheStorage, NoCacheStorage
using Enzyme
using EnzymeCore
using EnzymeCore.EnzymeRules

# =============================================================================
# Mark cache-storage types as inactive
# =============================================================================
# `SingleCacheStorage` and `DictCacheStorage` are mutable / contain a `Dict`,
# and their cache-miss branches write to that storage. Without these
# declarations Enzyme conservatively treats any closure that *might* touch a
# `FunctionWrappersWrapper` (e.g. via `remake(prob; p = …)` capturing the
# problem in scope) as potentially writing to the wrapper's cache, and
# refuses to prove the captured argument read-only. The cache values are
# `FunctionWrapper`s used purely for dispatch / dynamic call speedup; they
# never hold derivative data.
EnzymeCore.EnzymeRules.inactive_type(::Type{<:SingleCacheStorage}) = true
EnzymeCore.EnzymeRules.inactive_type(::Type{<:DictCacheStorage}) = true
EnzymeCore.EnzymeRules.inactive_type(::Type{NoCacheStorage}) = true

# =============================================================================
# Helper: build a Forward mode from FwdConfig flags
# =============================================================================
Expand Down
Loading