-
Notifications
You must be signed in to change notification settings - Fork 69
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
Inconsistency in mode type parameters for ReverseModeSplit
#1881
Comments
yeah thats definitely a bug, PR to fix is welcome! That sad the internal of this struct are not considered public API and subject to change. |
Do you mean that the precise order and nature of type parameters in each |
correct (and that's why we have helper functions) |
So if I understand correctly:
Sounds about right? If so, I might add some warnings here and there when I open the PR |
👍 |
to be clear the type parameters are generally stable, but subject to change if something needs to be added. The helper functions will always adapt to those changes, hence are the recommended way to use -- if needed. |
While we're on helper functions, it turns out I need the following ones for DI to work. Any comments on naming, and whether or not they're welcome in EnzymeCore? function mode_noprimal(
::Type{ForwardMode{ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}}
) where {ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}
return ForwardMode{false,ABI,ErrIfFuncWritten,RuntimeActivity}()
end
function mode_withprimal(
::Type{ForwardMode{ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}}
) where {ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}
return ForwardMode{true,ABI,ErrIfFuncWritten,RuntimeActivity}()
end
function mode_noprimal(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
return ReverseMode{false,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}()
end
function mode_withprimal(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
return ReverseMode{true,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}()
end
function mode_noprimal(
::Type{
ReverseModeSplit{
ReturnPrimal,
ReturnShadow,
RuntimeActivity,
Width,
ModifiedBetween,
ABI,
ErrIfFuncWritten,
},
},
) where {
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}
return ReverseModeSplit{
false,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()
end
function mode_withprimal(
::Type{
ReverseModeSplit{
ReturnPrimal,
ReturnShadow,
RuntimeActivity,
Width,
ModifiedBetween,
ABI,
ErrIfFuncWritten,
},
},
) where {
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}
return ReverseModeSplit{
true,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()
end
function mode_split(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
ReturnShadow = true
Width = 0
ModifiedBetween = true
return ReverseModeSplit{
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()
end |
Go for it but perhaps call them just WithPrimal and NoPrimal
…On Mon, Sep 23, 2024 at 10:30 AM Guillaume Dalle ***@***.***> wrote:
While we're on helper functions, it turns out I need the following ones
for DI to work. Any comments on naming, and whether or not they're welcome
in EnzymeCore?
function mode_noprimal(
::Type{ForwardMode{ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}}
) where {ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}
return ForwardMode{false,ABI,ErrIfFuncWritten,RuntimeActivity}()end
function mode_withprimal(
::Type{ForwardMode{ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}}
) where {ReturnPrimal,ABI,ErrIfFuncWritten,RuntimeActivity}
return ForwardMode{true,ABI,ErrIfFuncWritten,RuntimeActivity}()end
function mode_noprimal(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
return ReverseMode{false,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}()end
function mode_withprimal(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
return ReverseMode{true,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}()end
function mode_noprimal(
::Type{
ReverseModeSplit{
ReturnPrimal,
ReturnShadow,
RuntimeActivity,
Width,
ModifiedBetween,
ABI,
ErrIfFuncWritten,
},
},
) where {
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}
return ReverseModeSplit{
false,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()end
function mode_withprimal(
::Type{
ReverseModeSplit{
ReturnPrimal,
ReturnShadow,
RuntimeActivity,
Width,
ModifiedBetween,
ABI,
ErrIfFuncWritten,
},
},
) where {
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}
return ReverseModeSplit{
true,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()end
function mode_split(
::Type{ReverseMode{ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}}
) where {ReturnPrimal,RuntimeActivity,ABI,Holomorphic,ErrIfFuncWritten}
ReturnShadow = true
Width = 0
ModifiedBetween = true
return ReverseModeSplit{
ReturnPrimal,ReturnShadow,RuntimeActivity,Width,ModifiedBetween,ABI,ErrIfFuncWritten
}()end
—
Reply to this email directly, view it on GitHub
<#1881 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJTUXEOWROYIXUZ7DYJYHLZYAXYTAVCNFSM6AAAAABOVQX3U2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRYGY2DONRTGU>
.
You are receiving this because you commented.Message ID: <EnzymeAD/Enzyme.
***@***.***>
|
Sounds good. I'll open the PR tonight or tomorrow :) |
The docstring and the type definition disagree on the order of type parameters (switch between
Width
andRuntimeActivity
)Enzyme.jl/lib/EnzymeCore/src/EnzymeCore.jl
Lines 248 to 261 in 0c36c5a
The text was updated successfully, but these errors were encountered: