Skip to content

Commit 878afca

Browse files
committed
move after defn
1 parent 54183d1 commit 878afca

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/compiler/interface.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ end
102102

103103
# Param-style wrappers
104104

105+
"""
106+
Params([A, B])
107+
108+
Container for implicit parameters, used when differentiating
109+
a zero-argument funtion `() -> loss(A, B)` with respect to `A, B`.
110+
"""
111+
struct Params
112+
order::Buffer # {Any, Vector{Any}}
113+
params::IdSet{Any} # TODO store ids only
114+
end
115+
116+
Params() = Params(Buffer([], false), IdSet())
117+
Params(xs) = Params(Buffer(xs, false), IdSet(xs))
118+
Params(ps::Params) = ps
119+
Params(xs::Tuple) = Params(collect(xs))
120+
121+
@forward Params.order Base.iterate, Base.length, Base.getindex
122+
@forward Params.params Base.in
123+
105124
"""
106125
gradient(() -> loss(), ps::Params) -> Grads
107126
@@ -135,25 +154,6 @@ function withgradient(f, ps::Params)
135154
(val = y, grad = back(sensitivity(y)))
136155
end
137156

138-
"""
139-
Params([A, B])
140-
141-
Container for implicit parameters, used when differentiating
142-
a zero-argument funtion `() -> loss(A, B)` with respect to `A, B`.
143-
"""
144-
struct Params
145-
order::Buffer # {Any, Vector{Any}}
146-
params::IdSet{Any} # TODO store ids only
147-
end
148-
149-
Params() = Params(Buffer([], false), IdSet())
150-
Params(xs) = Params(Buffer(xs, false), IdSet(xs))
151-
Params(ps::Params) = ps
152-
Params(xs::Tuple) = Params(collect(xs))
153-
154-
@forward Params.order Base.iterate, Base.length, Base.getindex
155-
@forward Params.params Base.in
156-
157157
function Base.union!(ps::Params, itrs...)
158158
foreach(itr -> foreach(x -> push!(ps, x), itr), itrs)
159159
return ps

0 commit comments

Comments
 (0)