From 7a8e8f6496782d5641c7a0722e369668ef55cd98 Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Wed, 10 May 2023 19:07:15 +0700 Subject: [PATCH] refractoring --- src/SNNUtils.jl | 12 +++++++++++- src/interface.jl | 27 +++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/SNNUtils.jl b/src/SNNUtils.jl index e6ecc3d..5b236cb 100644 --- a/src/SNNUtils.jl +++ b/src/SNNUtils.jl @@ -1,6 +1,6 @@ module SNNUtils -# export +export timestepForward! include("interface.jl") using .interface @@ -8,6 +8,16 @@ using .interface #------------------------------------------------------------------------------------------------100 +""" + Todo: + - [*] implement kfn in Array of Struct version + + Change from version: - + - + + All features + - +""" diff --git a/src/interface.jl b/src/interface.jl index bbed925..1e54345 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -1,7 +1,7 @@ module interface -# export +export timestepForward! # using @@ -10,7 +10,13 @@ module interface #------------------------------------------------------------------------------------------------100 -abstract type knowledgeFn end +abstract type Ironpen end +abstract type knowledgeFn <: Ironpen end +abstract type neuron <: Ironpen end +abstract type input_neuron <: neuron end +abstract type output_neuron <: neuron end +abstract type compute_neuron <: neuron end +#------------------------------------------------------------------------------------------------100 mul!(x::AbstractVector, y::AbstractVector) = x .*= y mul(x::AbstractVector, y::AbstractVector) = x .* y @@ -24,6 +30,9 @@ function selectAdd!(x::AbstractVector, ind::AbstractVector, value::AbstractVecto @. x = x + (ind * value) end + + + function timestepForward!(kfn::T) where T<:knowledgeFn kfn.zt_1 .= kfn.zt0 kfn.zt0 .= 0 @@ -55,6 +64,20 @@ function timestepForward!(kfn::T) where T<:knowledgeFn updateVector!.(kfn.alif_epsilonRecA_t0, 0.0) end +function timestep_forward!(x::passthrough_neuron) +end + +function timestep_forward!(x::compute_neuron) + x.z_t = x.z_t1 + x.z_t1 = false + x.v_t = x.v_t1 +end + +function timestep_forward!(x::linear_neuron) + x.out_t = isnothing(x.out_t1) ? nothing : copy(x.out_t1) +end + + function resetParams!(kfn::T) where T<:knowledgeFn updateVector!(kfn.zt_1, 0.0) updateVector!(kfn.kfnError, 0.0)