Skip to content

Commit

Permalink
using new Get* funcs and fixed imports and undefined types.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Oct 11, 2024
1 parent 00cfcfe commit d9eafb7
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 303 deletions.
21 changes: 11 additions & 10 deletions axon/act.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions axon/act.goal
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/emer/axon/v2/chans"
)

///////////////////////////////////////////////////////////////////////
// act.go contains the activation params and functions for axon
//////// act.go contains the activation params and functions for axon

//gosl:start
//gosl:import "cogentcore.org/core/math32"
//gosl:import "cogentcore.org/core/math32/minmax"
//gosl:import "github.com/emer/axon/v2/chans"

//////////////////////////////////////////////////////////////////////////////////////
// SpikeParams
//////// SpikeParams

// SpikeParams contains spiking activation function params.
// Implements a basic thresholded Vm model, and optionally
Expand Down Expand Up @@ -122,8 +122,7 @@ func (sk *SpikeParams) AvgFromISI(avg float32, isi float32) float32 {
return avg
}

//////////////////////////////////////////////////////////////////////////////////////
// DendParams
//////// DendParams

// DendParams are the parameters for updating dendrite-specific dynamics
type DendParams struct {
Expand Down Expand Up @@ -172,8 +171,7 @@ func (dp *DendParams) ShouldDisplay(field string) bool {
}
}

//////////////////////////////////////////////////////////////////////////////////////
// ActInitParams
//////// ActInitParams

// ActInitParams are initial values for key network state variables.
// Initialized in InitActs called by InitWeights, and provides target values for DecayState.
Expand Down Expand Up @@ -212,6 +210,10 @@ func (ai *ActInitParams) Defaults() {
ai.GiVar = 0
}

//gosl:end

// note: these are only called in CPU during init.

// GeBase returns the baseline Ge value: Ge + rand(GeVar) > 0
func (ai *ActInitParams) GetGeBase(rnd randx.Rand) float32 {
ge := ai.GeBase
Expand Down Expand Up @@ -511,8 +513,7 @@ func (cp *ClampParams) Defaults() {
cp.ErrThr = 0.5
}

//////////////////////////////////////////////////////////////////////////////////////
// SMaintParams
//////// SMaintParams

// SMaintParams for self-maintenance simulating a population of
// NMDA-interconnected spiking neurons
Expand Down
11 changes: 0 additions & 11 deletions axon/avgmax.go → axon/avgmaxi.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@ func (am *AvgMaxI32) Calc(refIndex int32) {

//gosl:end

//gosl:wgsl avgmaxi
/*
// // AtomicUpdateAvgMaxI32 provides an atomic update using atomic ints
// // implemented by InterlockedAdd HLSL intrinsic.
// // This is a #define because it doesn't work on arg values --
// // must be directly operating on a RWStorageBuffer entity.
// // TODO:gosl do atomics!
// // #define AtomicUpdateAvgMaxI32(am, val) InterlockedAdd(am.Sum, am.FloatToIntSum(val)); InterlockedMax(am.CurMax, am.FloatToInt(val))
*/
//gosl:end avgmaxi

func (am *AvgMaxI32) String() string {
return fmt.Sprintf("{Avg: %g, Max: %g, N: %d}", am.Avg, am.Max, am.N)
}
3 changes: 3 additions & 0 deletions axon/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

//gosl:start
//gosl:import "github.com/emer/emergent/v2/etime"

// Context contains all of the global context state info
// that is shared across every step of the computation.
Expand Down Expand Up @@ -68,6 +69,8 @@ type Context struct {
// many are actually used. This is shared across all layers so must
// encompass all possible param settings.
RandCtr uint64

pad, pad1 float32
}

// Defaults sets default values
Expand Down
160 changes: 80 additions & 80 deletions axon/enumgen.go

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions axon/inhib.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ import (
"github.com/emer/axon/v2/fsfffb"
)

//gosl:wgsl inhib
// #include "fsfffb.wgsl"
//gosl:end inhib
//gosl:start
//gosl:import "github.com/emer/axon/v2/fsfffb"

//gosl:start inhib

///////////////////////////////////////////////////////////////////////
// ActAvgParams
//////// ActAvgParams

// ActAvgParams represents the nominal average activity levels in the layer
// and parameters for adapting the computed Gi inhibition levels to maintain
Expand Down Expand Up @@ -186,4 +182,4 @@ func (ip *InhibParams) Defaults() {
ip.Pool.Gi = 1.1
}

//gosl:end inhib
//gosl:end
61 changes: 2 additions & 59 deletions axon/layer-algo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 2 additions & 59 deletions axon/layer-algo.goal
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,8 @@ import (
// lni = layer-based neuron index (0 = first neuron in layer)
// ni = absolute network-level neuron index

// layer-algo.go has the core algorithm methods.

// LDTSrcLayAct returns the overall activity level for given source layer
// for purposes of computing ACh salience value.
// Typically the input is a superior colliculus (SC) layer that rapidly
// accommodates after the onset of a stimulus.
// using lpl.AvgMax.CaSpkP.Cycle.Max for layer activity measure.
func (ly *Layer) LDTSrcLayAct(net *Network, layIndex int32, di uint32) float32 {
if layIndex < 0 {
return 0
}
lay := net.Layers[layIndex]
lpl := lay.Pool(0, di)
return lpl.AvgMax.CaSpkP.Cycle.Avg
}

// CyclePost is called after the standard Cycle update, as a separate
// network layer loop.
// This is reserved for any kind of special ad-hoc types that
// need to do something special after Spiking is finally computed and Sent.
// Typically used for updating global values in the Context state,
// such as updating a neuromodulatory signal such as dopamine.
// Any updates here must also be done in gpu_wgsl/gpu_cyclepost.wgsl
func (ly *Layer) CyclePost(ctx *Context) {
net := ly.Network
for di := uint32(0); di < ctx.NData; di++ {
vals := ly.LayerValues(di)
lpl := ly.Pool(0, di)
ly.Params.CyclePostLayer(ctx, di, lpl, vals)
switch ly.Type {
case CeMLayer:
ly.Params.CyclePostCeMLayer(ctx, di, lpl)
case VSPatchLayer:
for pi := uint32(1); pi < ly.NPools; pi++ {
pl := ly.Pool(pi, di)
ly.Params.CyclePostVSPatchLayer(ctx, di, int32(pi), pl, vals)
}
case LDTLayer:
srcLay1Act := ly.LDTSrcLayAct(net, ly.Params.LDT.SrcLay1Index, di)
srcLay2Act := ly.LDTSrcLayAct(net, ly.Params.LDT.SrcLay2Index, di)
srcLay3Act := ly.LDTSrcLayAct(net, ly.Params.LDT.SrcLay3Index, di)
srcLay4Act := ly.LDTSrcLayAct(net, ly.Params.LDT.SrcLay4Index, di)
ly.Params.CyclePostLDTLayer(ctx, di, vals, srcLay1Act, srcLay2Act, srcLay3Act, srcLay4Act)
case VTALayer:
ly.Params.CyclePostVTALayer(ctx, di)
case RWDaLayer:
pvals := net.LayerValues(uint32(ly.Params.RWDa.RWPredLayIndex), di)
ly.Params.CyclePostRWDaLayer(ctx, di, vals, pvals)
case TDPredLayer:
ly.Params.CyclePostTDPredLayer(ctx, di, vals)
case TDIntegLayer:
pvals := net.LayerValues(uint32(ly.Params.TDInteg.TDPredLayIndex), di)
ly.Params.CyclePostTDIntegLayer(ctx, di, vals, pvals)
case TDDaLayer:
ivals := net.LayerValues(uint32(ly.Params.TDDa.TDIntegLayIndex), di)
ly.Params.CyclePostTDDaLayer(ctx, di, vals, ivals)
}
}
}
// layer-algo.goal has supporting CPU-only algorithm methods
// layerparams.goal has core GPU / CPU code.

//////////////////////////////////////////////////////////////////////////////////////
// Phase-level
Expand Down
Loading

0 comments on commit d9eafb7

Please sign in to comment.