obviate mapconst
This commit is contained in:
parent
c969d13306
commit
45c5502f90
@ -1,4 +1,4 @@
|
|||||||
import DataFlow: mapconst, cse
|
import DataFlow: cse
|
||||||
using MacroTools: @q
|
using MacroTools: @q
|
||||||
|
|
||||||
export @net
|
export @net
|
||||||
@ -6,7 +6,7 @@ export @net
|
|||||||
function graphdef(ex, params = [])
|
function graphdef(ex, params = [])
|
||||||
@capture(shortdef(ex), (args__,) -> body_)
|
@capture(shortdef(ex), (args__,) -> body_)
|
||||||
body = @> body MacroTools.flatten liftloops graphm DataFlow.il
|
body = @> body MacroTools.flatten liftloops graphm DataFlow.il
|
||||||
body = mapconst(x -> x in params ? :(self.$x) : x, body)
|
body = map(x -> x in params ? :(self.$x) : x, body)
|
||||||
return args, body
|
return args, body
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ end
|
|||||||
|
|
||||||
import Lazy: groupby
|
import Lazy: groupby
|
||||||
|
|
||||||
reifyparams(v::IVertex) = mapconst(x -> x isa Param ? x.x : x, v)
|
reifyparams(v::IVertex) = map(x -> x isa Param ? x.x : x, v)
|
||||||
|
|
||||||
# TODO: type hints for parameters
|
# TODO: type hints for parameters
|
||||||
|
|
||||||
@ -69,14 +69,14 @@ function process_type(ex)
|
|||||||
$(build_type(T, params))
|
$(build_type(T, params))
|
||||||
$(esc(:((self::$T)($(args...)) = $(build_forward(body, args)))))
|
$(esc(:((self::$T)($(args...)) = $(build_forward(body, args)))))
|
||||||
$(esc(:(Flux.update!(self::$T, η)))) = ($(map(p -> :(update!($self.$p, η)), pnames)...);)
|
$(esc(:(Flux.update!(self::$T, η)))) = ($(map(p -> :(update!($self.$p, η)), pnames)...);)
|
||||||
$(esc(:(Flux.graph(self::$T)))) = $(DataFlow.constructor(mapconst(esc, makegraph(body, args, params))))
|
$(esc(:(Flux.graph(self::$T)))) = $(DataFlow.constructor(map(esc, makegraph(body, args, params))))
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_anon(ex)
|
function process_anon(ex)
|
||||||
args, body = graphdef(ex)
|
args, body = graphdef(ex)
|
||||||
:(Capacitor($(DataFlow.constructor(mapconst(esc, makegraph(body, args)[1])))))
|
:(Capacitor($(DataFlow.constructor(map(esc, makegraph(body, args)[1])))))
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_def(ex)
|
function process_def(ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user