-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
535 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ model_weights | |
docs/docs | ||
docs/site | ||
|
||
scripts | ||
scripts | ||
test_ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
name = "Lux" | ||
uuid = "b2108857-7c20-44ae-9111-449ecde12c47" | ||
authors = ["Avik Pal <[email protected]> and contributors"] | ||
version = "0.4.36" | ||
version = "0.4.37" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" | ||
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" | ||
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" | ||
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623" | ||
|
@@ -26,11 +27,12 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | |
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" | ||
|
||
[weakdeps] | ||
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" | ||
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" | ||
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" | ||
|
||
[extensions] | ||
Flux2LuxExt = ["Flux", "Optimisers"] | ||
LuxComponentArraysExt = "ComponentArrays" | ||
LuxFluxTransformExt = "Flux" | ||
|
||
[compat] | ||
Adapt = "3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module LuxComponentArraysExt | ||
|
||
isdefined(Base, :get_extension) ? (using ComponentArrays) : (using ..ComponentArrays) | ||
|
||
using Functors, Lux, Optimisers, Zygote | ||
|
||
@inline function Lux._getproperty(x::ComponentArray, ::Val{prop}) where {prop} | ||
return prop in propertynames(x) ? getproperty(x, prop) : nothing | ||
end | ||
|
||
function Functors.functor(::Type{<:ComponentArray}, c) | ||
return NamedTuple{propertynames(c)}(getproperty.((c,), propertynames(c))), | ||
ComponentArray | ||
end | ||
|
||
# Zygote Fixes | ||
function Zygote.accum(x::ComponentArray, ys::ComponentArray...) | ||
return ComponentArray(Zygote.accum(getdata(x), getdata.(ys)...), getaxes(x)) | ||
end | ||
|
||
# Optimisers Fixes | ||
Optimisers.setup(opt::AbstractRule, ps::ComponentArray) = Optimisers.setup(opt, getdata(ps)) | ||
|
||
function Optimisers.update(tree, ps::ComponentArray, gs::ComponentArray) | ||
tree, ps_new = Optimisers.update(tree, getdata(ps), getdata(gs)) | ||
return tree, ComponentArray(ps_new, getaxes(ps)) | ||
end | ||
|
||
function Optimisers.update!(tree::Optimisers.Leaf, ps::ComponentArray, gs::ComponentArray) | ||
tree, ps_new = Optimisers.update!(tree, getdata(ps), getdata(gs)) | ||
return tree, ComponentArray(ps_new, getaxes(ps)) | ||
end | ||
|
||
# Freezing | ||
Lux._merge(nt1::ComponentArray, nt2::NamedTuple) = merge(NamedTuple(nt1), nt2) | ||
Lux._merge(nt1::NamedTuple, nt2::ComponentArray) = merge(nt1, NamedTuple(nt2)) | ||
|
||
# Parameter Sharing | ||
Lux._parameter_structure(ps::ComponentArray) = Lux._parameter_structure(NamedTuple(ps)) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.