-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vc/fixup isapplicable use v2 (#2158)
* Forward interp and sv to isapplicable * invalidation for inactive now works * move tfunc to compilers * fixup! move tfunc to compilers * fixup! fixup! move tfunc to compilers * add ephermal cache * bump versions --------- Co-authored-by: William S. Moses <[email protected]>
- Loading branch information
Showing
6 changed files
with
85 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "EnzymeCore" | ||
uuid = "f151be2c-9106-41f4-ab19-57ee4f262869" | ||
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>"] | ||
version = "0.8.7" | ||
version = "0.8.8" | ||
|
||
[compat] | ||
Adapt = "3, 4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import EnzymeCore: Annotation | ||
import EnzymeCore.EnzymeRules: FwdConfig, RevConfig, forward, augmented_primal, inactive, _annotate_tt | ||
|
||
function has_frule_from_sig(@nospecialize(interp::Core.Compiler.AbstractInterpreter), | ||
@nospecialize(TT), sv::Core.Compiler.AbsIntState)::Bool | ||
ft, tt = _annotate_tt(TT) | ||
TT = Tuple{<:FwdConfig,<:Annotation{ft},Type{<:Annotation},tt...} | ||
return isapplicable(interp, forward, TT, sv) | ||
end | ||
|
||
function has_rrule_from_sig(@nospecialize(interp::Core.Compiler.AbstractInterpreter), | ||
@nospecialize(TT), sv::Core.Compiler.AbsIntState)::Bool | ||
ft, tt = _annotate_tt(TT) | ||
TT = Tuple{<:RevConfig,<:Annotation{ft},Type{<:Annotation},tt...} | ||
return isapplicable(interp, augmented_primal, TT, sv) | ||
end | ||
|
||
|
||
function is_inactive_from_sig(@nospecialize(interp::Core.Compiler.AbstractInterpreter), | ||
@nospecialize(TT), sv::Core.Compiler.AbsIntState) | ||
return isapplicable(interp, inactive, TT, sv) | ||
end | ||
|
||
# `hasmethod` is a precise match using `Core.Compiler.findsup`, | ||
# but here we want the broader query using `Core.Compiler.findall`. | ||
# Also add appropriate backedges to the caller `MethodInstance` if given. | ||
function isapplicable(@nospecialize(interp::Core.Compiler.AbstractInterpreter), | ||
@nospecialize(f), @nospecialize(TT), sv::Core.Compiler.AbsIntState)::Bool | ||
tt = Base.to_tuple_type(TT) | ||
sig = Base.signature_type(f, tt) | ||
mt = ccall(:jl_method_table_for, Any, (Any,), sig) | ||
mt isa Core.MethodTable || return false | ||
result = Core.Compiler.findall(sig, Core.Compiler.method_table(interp); limit=-1) | ||
(result === nothing || result === missing) && return false | ||
@static if isdefined(Core.Compiler, :MethodMatchResult) | ||
(; matches) = result | ||
else | ||
matches = result | ||
end | ||
# also need an edge to the method table in case something gets | ||
# added that did not intersect with any existing method | ||
fullmatch = Core.Compiler._any(match::Core.MethodMatch -> match.fully_covers, matches) | ||
if !fullmatch | ||
Core.Compiler.add_mt_backedge!(sv, mt, sig) | ||
end | ||
if Core.Compiler.isempty(matches) | ||
return false | ||
else | ||
for i = 1:Core.Compiler.length(matches) | ||
match = Core.Compiler.getindex(matches, i)::Core.MethodMatch | ||
edge = Core.Compiler.specialize_method(match)::Core.MethodInstance | ||
Core.Compiler.add_backedge!(sv, edge) | ||
end | ||
return true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6606cd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register subdir="lib/EnzymeCore"
6606cd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/120705
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
6606cd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
6606cd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/120707
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: