Skip to content

Commit 159837e

Browse files
committed
cleanup and fix
1 parent 5ddab93 commit 159837e

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/Enzyme.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ function overload_autodiff(
321321
argprefix,
322322
resprefix,
323323
resargprefix,
324-
within_autodiff=true,
325324
)
326325
(; result, linear_args, in_tys, linear_results) = mlir_fn_res
327326
fnwrap = mlir_fn_res.fnwrapped

src/Interpreter.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ end
9090
struct ReactantCacheToken end
9191

9292
function ReactantInterpreter(;
93-
world::UInt=Base.get_world_counter(), within_autodiff=false
93+
world::UInt=Base.get_world_counter()
9494
)
9595
return Enzyme.Compiler.Interpreter.EnzymeInterpreter(
9696
ReactantCacheToken(),
9797
REACTANT_METHOD_TABLE,
9898
world,
99-
false, #=forward_rules=#
100-
false, #=reverse_rules=#
101-
false, #=inactive_rules=#
102-
false, #=broadcast_rewrite=#
103-
within_autodiff, #=within_autodiff_rewrite=#
99+
false, #=forward_rules=#
100+
false, #=reverse_rules=#
101+
false, #=inactive_rules=#
102+
false, #=broadcast_rewrite=#
103+
false, #=within_autodiff_rewrite=#
104104
set_reactant_abi,
105105
)
106106
end
@@ -110,17 +110,16 @@ else
110110
function ReactantInterpreter(;
111111
world::UInt=Base.get_world_counter(),
112112
code_cache=REACTANT_CACHE,
113-
within_autodiff=false,
114113
)
115114
return Enzyme.Compiler.Interpreter.EnzymeInterpreter(
116115
REACTANT_CACHE,
117116
REACTANT_METHOD_TABLE,
118117
world,
119-
false, #=forward_rules=#
120-
false, #=reverse_rules=#
121-
false, #=inactive_rules=#
122-
false, #=broadcast_rewrite=#
123-
within_autodiff, #=within_autodiff_rewrite=#
118+
false, #=forward_rules=#
119+
false, #=reverse_rules=#
120+
false, #=inactive_rules=#
121+
false, #=broadcast_rewrite=#
122+
false, #=within_autodiff_rewrite=#
124123
set_reactant_abi,
125124
)
126125
end

src/Overlay.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ end
3030
@reactant_overlay @noinline function Enzyme.autodiff(
3131
rmode::Enzyme.Mode, f::FA, rt::Type{A}, args::Vararg{Annotation,Nargs}
3232
) where {FA<:Annotation,A<:Annotation,Nargs}
33-
return overload_autodiff(rmode, f, rt, args...)
33+
original_within_autodiff = WITHIN_AUTODIFF[]
34+
try
35+
WITHIN_AUTODIFF[] = true
36+
return overload_autodiff(rmode, f, rt, args...)
37+
finally
38+
WITHIN_AUTODIFF[] = original_within_autodiff
39+
end
3440
end
3541

3642
@reactant_overlay function EnzymeCore.ignore_derivatives(args...)

src/utils.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function apply(f::F, args...; kwargs...) where {F}
1919
end
2020

2121
function call_with_reactant end
22-
function call_with_reactant_within_autodiff end
2322

2423
function maybe_argextype(@nospecialize(x), src)
2524
return try

0 commit comments

Comments
 (0)