Skip to content

Commit

Permalink
Merge pull request #268 from slimgroup/ext-fix
Browse files Browse the repository at this point in the history
fix flux extension
  • Loading branch information
mloubout authored Aug 4, 2024
2 parents 9458f55 + 2111769 commit 9d95da7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JUDI"
uuid = "f3b833dc-6b2e-5b9c-b940-873ed6319979"
authors = ["Philipp Witte, Mathias Louboutin"]
version = "3.4.5"
version = "3.4.6"

This comment has been minimized.

Copy link
@mloubout

mloubout Aug 4, 2024

Author Member

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down Expand Up @@ -33,6 +33,7 @@ TimerOutputs = "0.5"
julia = "1.6"

[extensions]
CUDAJUDIExt = "CUDA"
FluxJUDIExt = "Flux"
JLD2JUDIExt = "JLD2"
ZygoteJUDIExt = "Zygote"
Expand All @@ -49,6 +50,7 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
test = ["Aqua", "JLD2", "Printf", "Test", "TimerOutputs", "Flux"]

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
10 changes: 10 additions & 0 deletions ext/CUDAJUDIExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module CUDAJUDIExt

import JUDI: LazyPropagation, judiVector, eval_prop
isdefined(Base, :get_extension) ? (using CUDA) : (using ..CUDA)

CUDA.cu(F::LazyPropagation) = CUDA.cu(eval_prop(F))
CUDA.cu(x::Vector{Matrix{T}}) where T = [CUDA.cu(x[i]) for i=1:length(x)]
CUDA.cu(x::judiVector{T, Matrix{T}}) where T = judiVector{T, CUDA.CuMatrix{T}}(x.nsrc, x.geometry, CUDA.cu(x.data))

end
5 changes: 1 addition & 4 deletions ext/FluxJUDIExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
module FluxJUDIExt

import JUDI: LazyPropagation, judiVector, eval_prop
import JUDI: LazyPropagation
isdefined(Base, :get_extension) ? (using Flux) : (using ..Flux)

Flux.cpu(x::LazyPropagation) = Flux.cpu(eval_prop(x))
Flux.gpu(x::LazyPropagation) = Flux.gpu(eval_prop(x))
Flux.CUDA.cu(F::LazyPropagation) = Flux.CUDA.cu(eval_prop(F))
Flux.CUDA.cu(x::Vector{Matrix{T}}) where T = [Flux.CUDA.cu(x[i]) for i=1:length(x)]
Flux.CUDA.cu(x::judiVector{T, Matrix{T}}) where T = judiVector{T, Flux.CUDA.CuMatrix{T}}(x.nsrc, x.geometry, Flux.CUDA.cu(x.data))

end
6 changes: 6 additions & 0 deletions src/JUDI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ function __init__()
@info "Flux compat enabled"
include("../ext/FluxJUDIExt.jl")
end

# Additional Flux compat if in use
@require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" begin
@info "CUDA compat enabled"
include("../ext/CUDAJUDIExt.jl")
end
end

end
Expand Down

1 comment on commit 9d95da7

@JuliaRegistrator
Copy link

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/112383

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.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

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:

git tag -a v3.4.6 -m "<description of version>" 9d95da7b2194f1c31618135e456acd587df0720e
git push origin v3.4.6

Please sign in to comment.