Skip to content

Commit 5f627de

Browse files
committed
fix: circular dep due to Adapt
1 parent 2921418 commit 5f627de

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
44
version = "0.15.19"
55

66
[deps]
7+
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
78
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
89
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
910
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
@@ -14,7 +15,6 @@ StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
1415
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1516

1617
[weakdeps]
17-
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
1818
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
1919
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
2020
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
@@ -24,7 +24,6 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
2424
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2525

2626
[extensions]
27-
ComponentArraysAdaptExt = "Adapt"
2827
ComponentArraysGPUArraysExt = "GPUArrays"
2928
ComponentArraysOptimisersExt = "Optimisers"
3029
ComponentArraysRecursiveArrayToolsExt = "RecursiveArrayTools"

ext/ComponentArraysAdaptExt.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/ComponentArrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module ComponentArrays
33
import ChainRulesCore
44
import StaticArrayInterface, ArrayInterface, Functors
55
import ConstructionBase
6+
import Adapt
67

78
using LinearAlgebra
89
using StaticArraysCore: StaticArray, SArray, SVector, SMatrix

src/componentarray.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ function ComponentArray(data, ax::AbstractAxis...)
5858
return LazyArray(ComponentArray(x, axs...) for x in part_data)
5959
end
6060

61+
function Adapt.adapt_structure(to, x::ComponentArray)
62+
data = Adapt.adapt(to, getdata(x))
63+
return ComponentArray(data, getaxes(x))
64+
end
65+
66+
Adapt.adapt_storage(::Type{ComponentArray{T,N,A,Ax}}, xs::AT) where {T,N,A,Ax,AT<:AbstractArray} =
67+
Adapt.adapt_storage(A, xs)
68+
6169
# Entry from NamedTuple, Dict, or kwargs
6270
ComponentArray{T}(nt::NamedTuple) where T = ComponentArray(make_carray_args(T, nt)...)
6371
ComponentArray{T}(::NamedTuple{(), Tuple{}}) where T = ComponentArray(T[], (FlatAxis(),))

0 commit comments

Comments
 (0)