-
Notifications
You must be signed in to change notification settings - Fork 63
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
active_reg_inner
returns DupState
for immutable struct with untyped field
#2039
Comments
No because the float variable must be boxed (and thus duplicated)
…On Thu, Oct 31, 2024 at 2:46 PM Daniel Wennberg ***@***.***> wrote:
Consider this:
julia> struct Foo
x
end
julia> Enzyme.Compiler.active_reg_inner(Foo, (), nothing)
DupState::ActivityState = 2
julia> Enzyme.Compiler.active_reg_inner(Foo, (), nothing, Val(true)) # justActive
AnyState::ActivityState = 0
The way I've understood it, DupState implies that all differentiable
values reachable from an object can be mutated, i.e., that there's some
mutable container along the chain of references from the object to each
differentiable value. But this isn't known from the type of Foo. The
simplest counterexample is Foo(1.0). Then again, it could be true, like
in Foo([1.0]). Wouldn't the appropriate return here be MixedState,
signaling that you should be prepared for both mutable and immutable values?
—
Reply to this email directly, view it on GitHub
<#2039>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTUXDO3YOUAJM4ZOXDUDDZ6KCIFAVCNFSM6AAAAABQ7AGLVWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYZDONRZGUZDEMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
No because the float variable must be boxed (and thus duplicated) |
Quick follow-up if you can spare another second, just to help my understanding: I get that the value is held in a box, so you can mutate instances of Anyway, I notice that this doesn't currently work, even with |
Consider this:
The way I've understood it,
DupState
implies that all differentiable values reachable from an object can be mutated, i.e., that there's some mutable container along the chain of references from the object to each differentiable value. But this isn't known from the type ofFoo
. The simplest counterexample isFoo(1.0)
. Then again, it could be true, like inFoo([1.0])
. Wouldn't the appropriate return here beMixedState
, signaling that you should be prepared for both mutable and immutable values?The text was updated successfully, but these errors were encountered: