-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure sparse backends and replace subtyping by traits (#40)
- Loading branch information
Showing
16 changed files
with
978 additions
and
381 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,13 +1,29 @@ | ||
name = "ADTypes" | ||
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" | ||
authors = ["Vaibhav Dixit <vaibhavyashdixit@gmail.com> and contributors"] | ||
version = "0.2.7" | ||
authors = [ | ||
"Vaibhav Dixit <vaibhavyashdixit@gmail.com>, Guillaume Dalle and contributors", | ||
] | ||
version = "1.0.0" | ||
|
||
[weakdeps] | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" | ||
|
||
[extensions] | ||
ADTypesChainRulesCoreExt = "ChainRulesCore" | ||
ADTypesEnzymeCoreExt = "EnzymeCore" | ||
|
||
[compat] | ||
julia = "1.6" | ||
ChainRulesCore = "1.23.0" | ||
EnzymeCore = "0.7.2" | ||
julia = "1.10" | ||
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" | ||
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] | ||
test = ["Aqua", "ChainRulesCore", "EnzymeCore", "JET", "Test"] |
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,29 @@ | ||
module ADTypesChainRulesCoreExt | ||
|
||
using ADTypes: ADTypes, AutoChainRules | ||
using ChainRulesCore: HasForwardsMode, HasReverseMode, | ||
NoForwardsMode, NoReverseMode, | ||
RuleConfig | ||
|
||
# see https://juliadiff.org/ChainRulesCore.jl/stable/rule_author/superpowers/ruleconfig.html | ||
|
||
function ADTypes.mode(::AutoChainRules{RC}) where { | ||
RC <: RuleConfig{>:HasForwardsMode} | ||
} | ||
return ADTypes.ForwardMode() | ||
end | ||
|
||
function ADTypes.mode(::AutoChainRules{RC}) where { | ||
RC <: RuleConfig{>:HasReverseMode} | ||
} | ||
return ADTypes.ReverseMode() | ||
end | ||
|
||
function ADTypes.mode(::AutoChainRules{RC}) where { | ||
RC <: RuleConfig{>:Union{HasForwardsMode, HasReverseMode}} | ||
} | ||
# more specific than the previous two | ||
return ADTypes.ForwardOrReverseMode() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ADTypesEnzymeCoreExt | ||
|
||
using ADTypes: ADTypes, AutoEnzyme | ||
using EnzymeCore: EnzymeCore | ||
|
||
ADTypes.mode(::AutoEnzyme{M}) where {M <: EnzymeCore.ForwardMode} = ADTypes.ForwardMode() | ||
ADTypes.mode(::AutoEnzyme{M}) where {M <: EnzymeCore.ReverseMode} = ADTypes.ReverseMode() | ||
|
||
end |
Oops, something went wrong.