Skip to content

Commit

Permalink
dummy implementation of flatten (#2205)
Browse files Browse the repository at this point in the history
* reintroduce flatten

* cleanup

* fix docs

* actually add docstring
  • Loading branch information
CarloLucibello authored Mar 10, 2023
1 parent a22a3bd commit 1258ddf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Documenter, Flux, NNlib, Functors, MLUtils, BSON, Optimisers, OneHotArrays, Zygote, ChainRulesCore, Plots, MLDatasets, Statistics, DataFrames


DocMeta.setdocmeta!(Flux, :DocTestSetup, :(using Flux); recursive = true)
DocMeta.setdocmeta!(Flux, :DocTestSetup,
:(using Flux; using Flux: flatten);
recursive = true)

makedocs(
modules = [Flux, NNlib, Functors, MLUtils, BSON, Optimisers, OneHotArrays, Zygote, ChainRulesCore, Base, Plots, MLDatasets, Statistics, DataFrames],
Expand Down
3 changes: 0 additions & 3 deletions src/deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ function update!(opt::Optimise.AbstractOptimiser, ::Params, grads::Union{Tuple,
""")
end

# https://github.com/FluxML/Flux.jl/issues/2195
const flatten = MLUtils.flatten

# v0.14 deprecations

# Enable these when 0.14 is released, and delete const ClipGrad = Optimise.ClipValue etc:
Expand Down
11 changes: 11 additions & 0 deletions src/layers/stateless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ function ChainRulesCore.rrule(::typeof(_match_eltype), layer, x::AbstractArray)
_match_eltype(layer, x), dx -> (ZeroTangent(), NoTangent(), dx) # does not un-thunk dx
end

# We have to define our own flatten in order
# to load previously saved models.
# See #2195 #2204
"""
flatten(x)
Same as [`MLUtils.flatten`](@ref), which
should be prefered to this method existing
only for backward compatibility.
"""
flatten(x) = MLUtils.flatten(x)

2 comments on commit 1258ddf

@CarloLucibello
Copy link
Member Author

Choose a reason for hiding this comment

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

@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/79377

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 v0.13.14 -m "<description of version>" 1258ddf76fa09ffbad9a1ad3a0ca7b35bf9efe67
git push origin v0.13.14

Please sign in to comment.