Skip to content

Commit

Permalink
Add Flux support via Require
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Oct 18, 2018
1 parent 1f89c1a commit 5184e94
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ function __init__()
@inline ODE_DEFAULT_NORM(u::Unitful.Quantity) = abs(value(u))
end

@require Flux="587475ba-b771-5e3f-ad9e-33799f191a9c" begin
value(x::Flux.Tracker.TrackedReal) = x.data
value(x::Flux.Tracker.TrackedArray) = x.data
@inline function ODE_DEFAULT_NORM(u::Flux.Tracker.TrackedArray) where {N}
sqrt(sum(ODE_DEFAULT_NORM,(value(x) for x in u)) / length(u))
end
@inline ODE_DEFAULT_NORM(u::Flux.Tracker.TrackedReal) = abs(value(u))
end

end

0 comments on commit 5184e94

Please sign in to comment.