Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Adapt unconditionally for Julia 1.8 #1369

Merged
merged 5 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ steps:
matrix:
setup:
version:
- "1.8"
- "1.9"
- "1.10"
plugins:
Expand Down
5 changes: 4 additions & 1 deletion lib/EnzymeCore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ version = "0.7.1"
Adapt = "3, 4"
julia = "1.6"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, this doesn't add the dep on 1.9+?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, on Julia >= 1.9 it will still be only a weak dependency.


[extensions]
AdaptExt = "Adapt"

[extras]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
26 changes: 17 additions & 9 deletions lib/EnzymeCore/ext/AdaptExt.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module AdaptExt
using Adapt
using EnzymeCore

Adapt.adapt_structure(to, x::Const) = Const(adapt(to, x.val))
Adapt.adapt_structure(to, x::Active) = Active(adapt(to, x.val))
Adapt.adapt_structure(to, x::Duplicated) = Duplicated(adapt(to, x.val), adapt(to, x.dval))
Adapt.adapt_structure(to, x::DuplicatedNoNeed) = DuplicatedNoNeed(adapt(to, x.val), adapt(to, x.dval))
Adapt.adapt_structure(to, x::BatchDuplicated) = BatchDuplicated(adapt(to, x.val), adapt(to, x.dval))
Adapt.adapt_structure(to, x::BatchDuplicatedNoNeed) = BatchDuplicatedNoNeed(adapt(to, x.val), adapt(to, x.dval))
end
using Adapt
using EnzymeCore

Adapt.adapt_structure(to, x::Const) = Const(adapt(to, x.val))
Adapt.adapt_structure(to, x::Active) = Active(adapt(to, x.val))
Adapt.adapt_structure(to, x::Duplicated) = Duplicated(adapt(to, x.val), adapt(to, x.dval))
function Adapt.adapt_structure(to, x::DuplicatedNoNeed)
return DuplicatedNoNeed(adapt(to, x.val), adapt(to, x.dval))
end
function Adapt.adapt_structure(to, x::BatchDuplicated)
return BatchDuplicated(adapt(to, x.val), adapt(to, x.dval))
end
function Adapt.adapt_structure(to, x::BatchDuplicatedNoNeed)
return BatchDuplicatedNoNeed(adapt(to, x.val), adapt(to, x.dval))
end

end #module
4 changes: 4 additions & 0 deletions lib/EnzymeCore/src/EnzymeCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,8 @@ function compiler_job_from_backend end

include("rules.jl")

if !isdefined(Base, :get_extension)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include("../ext/AdaptExt.jl")
end

end # module EnzymeCore
Loading