Skip to main content

NeuronArray

Struct NeuronArray 

Source
pub struct NeuronArray<T, const N: usize>
where T: NeuralValue,
{
Show 17 fields pub count: usize, pub membrane_potentials: [T; N], pub thresholds: [T; N], pub threshold_limits: [T; N], pub leak_coefficients: [f32; N], pub resting_potentials: [T; N], pub neuron_types: [i32; N], pub refractory_periods: [u16; N], pub refractory_countdowns: [u16; N], pub excitabilities: [f32; N], pub consecutive_fire_counts: [u16; N], pub consecutive_fire_limits: [u16; N], pub snooze_periods: [u16; N], pub mp_charge_accumulation: [bool; N], pub cortical_areas: [u32; N], pub coordinates: [u32; N], pub valid_mask: [bool; N],
}
Expand description

Fixed-size neuron array for embedded systems

All data is stack-allocated with compile-time size limits. No heap allocations, perfect for no_std environments. Generic over T: NeuralValue to support multiple quantization levels.

§Example

use feagi_npu_runtime::embedded::NeuronArray;

// 100-neuron array on the stack (~5 KB for f32)
let mut neurons = NeuronArray::<f32, 100>::new();
neurons.add_neuron_simple(1.0, 0.1, 5, 1.0);

Fields§

§count: usize

Current number of neurons

§membrane_potentials: [T; N]

Membrane potentials (quantized to T)

§thresholds: [T; N]

Firing thresholds (quantized to T) - minimum MP to fire

§threshold_limits: [T; N]

Firing threshold limits (quantized to T) - maximum MP to fire (0 = no limit)

§leak_coefficients: [f32; N]

Leak coefficients (kept as f32 for precision)

§resting_potentials: [T; N]

Resting potentials

§neuron_types: [i32; N]

Neuron types (0=excitatory, 1=inhibitory)

§refractory_periods: [u16; N]

Refractory periods

§refractory_countdowns: [u16; N]

Refractory countdowns (state)

§excitabilities: [f32; N]

Excitability factors

§consecutive_fire_counts: [u16; N]

Consecutive fire counts

§consecutive_fire_limits: [u16; N]

Consecutive fire limits

§snooze_periods: [u16; N]

Snooze periods (extended refractory)

§mp_charge_accumulation: [bool; N]

Membrane potential charge accumulation flags

§cortical_areas: [u32; N]

Cortical area IDs

§coordinates: [u32; N]

3D coordinates (flat: [x0,y0,z0, x1,y1,z1, …])

§valid_mask: [bool; N]

Valid mask

Implementations§

Source§

impl<T, const N: usize> NeuronArray<T, N>
where T: NeuralValue,

Source

pub fn new() -> NeuronArray<T, N>

Create a new fixed-size neuron array

All arrays are zero-initialized on the stack. Note: Not const due to T::zero() trait method

Source§

impl<T, const N: usize> NeuronArray<T, N>
where T: NeuralValue,

Source

pub fn add_neuron_simple( &mut self, threshold: T, leak: f32, refractory_period: u16, excitability: f32, ) -> Option<usize>

Add a neuron (simplified for backward compatibility)

Returns the neuron index, or None if array is full.

Source

pub fn process_burst( &mut self, candidate_potentials: &[T; N], fired_mask: &mut [bool; N], ) -> usize

Process burst (single-threaded, deterministic)

Uses platform-agnostic core functions internally. Returns number of neurons that fired.

§Arguments
  • candidate_potentials - Input currents for each neuron
  • fired_mask - Output: which neurons fired (caller-allocated)
§Example
let mut neurons = NeuronArray::<f32, 100>::new();
let inputs = [1.5; 100];
let mut fired = [false; 100];
let count = neurons.process_burst(&inputs, &mut fired);
Source

pub const fn memory_footprint() -> usize

Get memory footprint in bytes

Trait Implementations§

Source§

impl<T, const N: usize> Default for NeuronArray<T, N>
where T: NeuralValue,

Source§

fn default() -> NeuronArray<T, N>

Returns the “default value” for a type. Read more
Source§

impl<T, const N: usize> NeuronStorage for NeuronArray<T, N>
where T: NeuralValue,

Source§

type Value = T

Numeric type for membrane potentials (f32, INT8Value, etc.)
Source§

fn membrane_potentials(&self) -> &[<NeuronArray<T, N> as NeuronStorage>::Value]

Membrane potentials slice
Source§

fn thresholds(&self) -> &[<NeuronArray<T, N> as NeuronStorage>::Value]

Firing thresholds slice (minimum MP to fire)
Source§

fn threshold_limits(&self) -> &[<NeuronArray<T, N> as NeuronStorage>::Value]

Firing threshold limits slice (maximum MP to fire, 0 = no limit)
Source§

fn leak_coefficients(&self) -> &[f32]

Leak coefficients slice (0.0-1.0)
Source§

fn resting_potentials(&self) -> &[<NeuronArray<T, N> as NeuronStorage>::Value]

Resting potentials slice
Source§

fn neuron_types(&self) -> &[i32]

Neuron types slice (0=excitatory, 1=inhibitory, etc.)
Source§

fn refractory_periods(&self) -> &[u16]

Refractory periods slice (burst counts)
Source§

fn refractory_countdowns(&self) -> &[u16]

Refractory countdowns slice (current state)
Source§

fn excitabilities(&self) -> &[f32]

Excitability factors slice (0.0-1.0)
Source§

fn consecutive_fire_counts(&self) -> &[u16]

Consecutive fire counts slice
Source§

fn consecutive_fire_limits(&self) -> &[u16]

Consecutive fire limits slice (0 = unlimited)
Source§

fn snooze_periods(&self) -> &[u16]

Snooze periods slice (extended refractory)
Source§

fn mp_charge_accumulation(&self) -> &[bool]

Membrane potential charge accumulation flags
Source§

fn cortical_areas(&self) -> &[u32]

Cortical area IDs slice
Source§

fn coordinates(&self) -> &[u32]

3D coordinates slice (flat array: [x0, y0, z0, x1, y1, z1, …])
Source§

fn valid_mask(&self) -> &[bool]

Valid neuron mask
Source§

fn membrane_potentials_mut( &mut self, ) -> &mut [<NeuronArray<T, N> as NeuronStorage>::Value]

Mutable membrane potentials slice
Source§

fn thresholds_mut( &mut self, ) -> &mut [<NeuronArray<T, N> as NeuronStorage>::Value]

Mutable firing thresholds slice
Source§

fn threshold_limits_mut( &mut self, ) -> &mut [<NeuronArray<T, N> as NeuronStorage>::Value]

Mutable firing threshold limits slice
Source§

fn leak_coefficients_mut(&mut self) -> &mut [f32]

Mutable leak coefficients slice
Source§

fn resting_potentials_mut( &mut self, ) -> &mut [<NeuronArray<T, N> as NeuronStorage>::Value]

Mutable resting potentials slice
Source§

fn neuron_types_mut(&mut self) -> &mut [i32]

Mutable neuron types slice
Source§

fn refractory_periods_mut(&mut self) -> &mut [u16]

Mutable refractory periods slice
Source§

fn refractory_countdowns_mut(&mut self) -> &mut [u16]

Mutable refractory countdowns slice
Source§

fn excitabilities_mut(&mut self) -> &mut [f32]

Mutable excitability factors slice
Source§

fn consecutive_fire_counts_mut(&mut self) -> &mut [u16]

Mutable consecutive fire counts slice
Source§

fn consecutive_fire_limits_mut(&mut self) -> &mut [u16]

Mutable consecutive fire limits slice
Source§

fn snooze_periods_mut(&mut self) -> &mut [u16]

Mutable snooze periods slice
Source§

fn mp_charge_accumulation_mut(&mut self) -> &mut [bool]

Mutable membrane potential charge accumulation flags
Source§

fn valid_mask_mut(&mut self) -> &mut [bool]

Mutable valid mask
Source§

fn count(&self) -> usize

Number of neurons currently stored
Source§

fn capacity(&self) -> usize

Maximum capacity
Source§

fn add_neuron( &mut self, threshold: <NeuronArray<T, N> as NeuronStorage>::Value, threshold_limit: <NeuronArray<T, N> as NeuronStorage>::Value, leak: f32, resting: <NeuronArray<T, N> as NeuronStorage>::Value, neuron_type: i32, refractory_period: u16, excitability: f32, consecutive_fire_limit: u16, snooze_period: u16, mp_charge_accumulation: bool, cortical_area: u32, x: u32, _y: u32, _z: u32, ) -> Result<usize, RuntimeError>

Add a single neuron
Source§

fn add_neurons_batch( &mut self, thresholds: &[<NeuronArray<T, N> as NeuronStorage>::Value], threshold_limits: &[<NeuronArray<T, N> as NeuronStorage>::Value], leak_coefficients: &[f32], resting_potentials: &[<NeuronArray<T, N> as NeuronStorage>::Value], neuron_types: &[i32], refractory_periods: &[u16], excitabilities: &[f32], consecutive_fire_limits: &[u16], snooze_periods: &[u16], mp_charge_accumulations: &[bool], cortical_areas: &[u32], x_coords: &[u32], y_coords: &[u32], z_coords: &[u32], ) -> Result<(), RuntimeError>

Batch add neurons (SIMD-optimized) Read more
Source§

fn get_neuron_at_coordinate( &self, cortical_area: u32, x: u32, _y: u32, _z: u32, ) -> Option<usize>

Get neuron at specific 3D coordinate in a cortical area
Source§

fn get_neuron_count(&self, cortical_area: u32) -> usize

Get count of neurons in a cortical area
Source§

fn get_cortical_area(&self, neuron_idx: usize) -> Option<u32>

Get cortical area ID for a neuron
Source§

fn get_coordinates(&self, neuron_idx: usize) -> Option<(u32, u32, u32)>

Get 3D coordinates for a neuron

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for NeuronArray<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for NeuronArray<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for NeuronArray<T, N>

§

impl<T, const N: usize> Sync for NeuronArray<T, N>

§

impl<T, const N: usize> Unpin for NeuronArray<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for NeuronArray<T, N>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.