Skip to content

Commit

Permalink
Fix getfield runtime activity (#2231)
Browse files Browse the repository at this point in the history
* fix

* Fix getfield runtime activity
  • Loading branch information
wsmoses authored Dec 26, 2024
1 parent 902faad commit 5afff0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/rules/typeunstablerules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,18 @@ function common_jl_getfield_fwd(offset, B, orig, gutils, normalR, shadowR)
end
unsafe_store!(shadowR, shadowres.ref)
else
normal = new_from_original(gutils, orig)

if !get_runtime_activity(gutils)
estr = "Mismatched activity for: " * string(orig) * " const input " *string(origops[2]) * ", differentiable return"
shadowres = julia_error(estr, orig.ref, API.ET_MixedActivityError, gutils.ref, orig.ref, B.ref)
if shadowres != C_NULL
unsafe_store!(shadowR, shadowres)
return true
end
end

normal = new_from_original(gutils, orig)

if width == 1
shadowres = normal
else
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,11 @@ function absactfunc(x)
end

@testset "Forward Mode active runtime activity" begin
res = Enzyme.autodiff(Enzyme.Forward, Enzyme.Const(absactfunc), Duplicated(2.7, 3.1))
@static if VERSION v"1.11-"
res = Enzyme.autodiff(set_runtime_activity(Enzyme.Forward), Enzyme.Const(absactfunc), Duplicated(2.7, 3.1))
else
res = Enzyme.autodiff(Enzyme.Forward, Enzyme.Const(absactfunc), Duplicated(2.7, 3.1))
end
@test res[1] 3.1
end

Expand Down

0 comments on commit 5afff0b

Please sign in to comment.