-
Notifications
You must be signed in to change notification settings - Fork 64
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
Check if function is being called inside autodiff
#1761
Comments
@wsmoses is this as simple as adding a |
we have this magic function: https://github.com/EnzymeAD/Enzyme/blob/7f614f43808e5bd3960f3712ac880b38eedc01d6/enzyme/test/Integration/ReverseMode/mycos.c#L39 which has the semantics that __enzyme_iter(x, y) = x if not differentiated, x + y on first order, etc [used for sake of keeping right order of taylor series]. It probably needs a bit of julia integration, but maybe something like this? |
Is this not an "actual" function present in the binary? I tried function within_autodiff()
return ccall((:__enzyme_iter, libEnzyme), UInt64, (UInt64, UInt64), 0, 1) != 0
end But that symbol is not present |
No it’s a fictitious one that Enzyme will replace with a definition (or
rather during AD transform as above).
Just like the enzyme pass we may need to tell enzyme to replace uses after
AD of the function with the first arg.
…On Sat, Aug 31, 2024 at 5:16 PM Avik Pal ***@***.***> wrote:
Is this not an "actual" function present in the binary? I tried
function within_autodiff()
return ccall((:__enzyme_iter, libEnzyme), UInt64, (UInt64, UInt64), 0, 1) != 0end
But that symbol is not present
—
Reply to this email directly, view it on GitHub
<#1761 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTUXGCTGJPWR6GMKNIHTDZUI6CPAVCNFSM6AAAAABNLKIX3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRTGA2TOMBRHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
hm okay I realize this won't quite work the same in Julia since we won't have control over the non differentiated optimizatio pipeline. I think the solution here is we just need to tell the abstract interpreter to block constprop for a special function which we rewrite if inside an enzyme differentiated context. cc @vchuravy @aviatesk I know some early work on absint overriding was here: #1443 but I think needs someone to push it forward atm |
Conversation from Slack
@avik-pal
In Enzyme can we check if a function is being called within an autodiff? Something equivalent to the following ChainRules version
I tried defining:
@wsmoses
I think this is getting optimized out lol
But yeah we can add something (c++ interface already has so we should bring parity to Julia for that :P)
(Julia will still constprop through things with enzyme rules atm)
The text was updated successfully, but these errors were encountered: