From c025cddc73c07c276c7bc47d7ab7f7fc7c09a5dd Mon Sep 17 00:00:00 2001 From: Mike J Innes Date: Thu, 4 May 2017 10:32:53 +0100 Subject: [PATCH] runmodel no longer needed --- src/compiler/code.jl | 7 +------ src/model.jl | 12 +----------- src/utils.jl | 2 ++ 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/compiler/code.jl b/src/compiler/code.jl index ce63b746..ac0980fe 100644 --- a/src/compiler/code.jl +++ b/src/compiler/code.jl @@ -39,15 +39,10 @@ function build_type(T, params) ex end -runmodel(f, xs...) = f(xs...) - function deref_params(v) - v = map(v) do x + map(v) do x x isa Constant && @capture(x.value, self.p_) ? Constant(:(Flux.state(self.$p))) : x end - prewalk(v) do v - @capture(value(v), self.p_) ? vertex(:(Flux.runmodel), constant(:(self.$p)), inputs(v)...) : v - end end function build_forward(body, args) diff --git a/src/model.jl b/src/model.jl index 279b0ed6..0793185e 100644 --- a/src/model.jl +++ b/src/model.jl @@ -46,16 +46,6 @@ methods as necessary. """ graph(m) = nothing -""" -`runmodel(m, ...)` is like `m(...)`, i.e. it runs the forward pass. However, -unlike direct calling, it does not try to apply batching and simply uses the -inputs directly. - -This function should be considered an implementation detail; it will be -eventually be replaced by a non-hacky way of doing batching. -""" -function runmodel end - # Model parameters # TODO: should be AbstractArray? @@ -125,7 +115,7 @@ Stateful(model, state) = Stateful(model, state, state) function (m::Stateful)(x) m.istate = m.ostate - state, y = runmodel(m.model, (m.istate...,), x) + state, y = m.model((m.istate...,), x) m.ostate = collect(state) return y end diff --git a/src/utils.jl b/src/utils.jl index 874cb9b2..d25f8e2b 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,5 +1,7 @@ export AArray, unsqueeze +call(f, xs...) = f(xs...) + # Arrays const AArray = AbstractArray