Skip to content

Commit

Permalink
refactor: use @static for preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jul 13, 2024
1 parent eafa652 commit e858e21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Lux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using ConcreteStructs: @concrete
using ConstructionBase: ConstructionBase
using EnzymeCore: EnzymeCore, EnzymeRules
using FastClosures: @closure
using ForwardDiff: ForwardDiff
using Functors: Functors, fmap
using GPUArraysCore: GPUArraysCore, @allowscalar
using LossFunctions: LossFunctions
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/nested_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end

function CRC.rrule(cfg::RuleConfig{>:HasReverseMode}, ::typeof(__internal_ad_gradient_call),
grad_fn::G, f::F, x, y) where {G, F}
if !AUTOMATIC_NESTED_AD_SWITCHING
@static if !AUTOMATIC_NESTED_AD_SWITCHING
return CRC.rrule_via_ad(
cfg, __internal_ad_gradient_call_no_custom_rrule, grad_fn, f, x, y)
end
Expand All @@ -76,7 +76,7 @@ end

function CRC.rrule(cfg::RuleConfig{>:HasReverseMode}, ::typeof(__internal_ad_pullback_call),
pullback_fn::P, f::F, x, y, u) where {P, F}
if !AUTOMATIC_NESTED_AD_SWITCHING
@static if !AUTOMATIC_NESTED_AD_SWITCHING
return CRC.rrule_via_ad(
cfg, __internal_ad_pullback_call_no_custom_rrule, pullback_fn, f, x, y, u)
end
Expand Down Expand Up @@ -110,7 +110,7 @@ end

function CRC.rrule(cfg::RuleConfig{>:HasReverseMode}, ::typeof(__internal_ad_jacobian_call),
jac_fn::J, grad_fn::G, f::F, x::AbstractArray, y) where {J, G, F}
if !AUTOMATIC_NESTED_AD_SWITCHING
@static if !AUTOMATIC_NESTED_AD_SWITCHING
return CRC.rrule_via_ad(
cfg, __internal_ad_jacobian_call_no_custom_rrule, jac_fn, grad_fn, f, x, y)
end
Expand Down

0 comments on commit e858e21

Please sign in to comment.