From f7c1c277b1854a46b39a04d581d8dc36cdaf1d5e Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 24 Mar 2021 16:29:47 +0000 Subject: [PATCH 1/3] Add qualification to at-nondifferentiable --- Project.toml | 2 +- src/rule_definition_tools.jl | 2 +- test/rule_definition_tools.jl | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index f951234a4..b213cc39d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ChainRulesCore" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.9.30" +version = "0.9.31" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" diff --git a/src/rule_definition_tools.jl b/src/rule_definition_tools.jl index 4b4c49d00..0a841409e 100644 --- a/src/rule_definition_tools.jl +++ b/src/rule_definition_tools.jl @@ -361,7 +361,7 @@ function _nondiff_rrule_expr(primal_sig_parts, primal_invoke) ) return esc(quote # Manually defined kw version to save compiler work. See explanation in rules.jl - function (::Core.kwftype(typeof(rrule)))(kwargs::Any, rrule::typeof(ChainRulesCore.rrule), $(primal_sig_parts...)) + function (::Core.kwftype(typeof(ChainRulesCore.rrule)))(kwargs::Any, rrule::typeof(ChainRulesCore.rrule), $(primal_sig_parts...)) return ($(_with_kwargs_expr(primal_invoke)), $pullback_expr) end function ChainRulesCore.rrule($(primal_sig_parts...)) diff --git a/test/rule_definition_tools.jl b/test/rule_definition_tools.jl index 75c03c86a..3b2520650 100644 --- a/test/rule_definition_tools.jl +++ b/test/rule_definition_tools.jl @@ -251,3 +251,24 @@ end end + + +module IsolatedModuleForTestingScoping + using Test + # need to make sure macros work in somethign that hasn't imported all exports + # all that matters is that the following don't error, since they will resolve at + # parse time + using ChainRulesCore: ChainRulesCore + + @testset "@non_differentiable" begin + # this is + # https://github.com/JuliaDiff/ChainRulesCore.jl/issues/317 + fixed(x) = :abc + ChainRulesCore.@non_differentiable fixed(x) + end + + @testset "scalar_rule" begin + my_id(x) = x + ChainRulesCore.@scalar_rule(my_id(x), 1.0) + end +end From 0751bfe4f9bf7d13b35a6451bf5dcd7907c5ea62 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 24 Mar 2021 16:31:25 +0000 Subject: [PATCH 2/3] consistent testset names --- test/rule_definition_tools.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rule_definition_tools.jl b/test/rule_definition_tools.jl index 3b2520650..6ad0ca770 100644 --- a/test/rule_definition_tools.jl +++ b/test/rule_definition_tools.jl @@ -267,7 +267,7 @@ module IsolatedModuleForTestingScoping ChainRulesCore.@non_differentiable fixed(x) end - @testset "scalar_rule" begin + @testset "@scalar_rule" begin my_id(x) = x ChainRulesCore.@scalar_rule(my_id(x), 1.0) end From 262f99b1e8b80c7b71337e4e04f912585f253dbe Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 24 Mar 2021 17:04:49 +0000 Subject: [PATCH 3/3] Update test/rule_definition_tools.jl Co-authored-by: David Widmann --- test/rule_definition_tools.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rule_definition_tools.jl b/test/rule_definition_tools.jl index 6ad0ca770..c563786ea 100644 --- a/test/rule_definition_tools.jl +++ b/test/rule_definition_tools.jl @@ -255,7 +255,7 @@ end module IsolatedModuleForTestingScoping using Test - # need to make sure macros work in somethign that hasn't imported all exports + # need to make sure macros work in something that hasn't imported all exports # all that matters is that the following don't error, since they will resolve at # parse time using ChainRulesCore: ChainRulesCore