Skip to content

Commit

Permalink
Refactor cleaning of eprop update history
Browse files Browse the repository at this point in the history
Co-authored-by: Agnes Korcsak-Gorzo 40828647+akorgor@users.noreply.github.com
  • Loading branch information
JesusEV committed Sep 9, 2024
1 parent afbebc4 commit e5446be
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
1 change: 0 additions & 1 deletion models/eprop_iaf_adapt_bsshslm_2020.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ eprop_iaf_adapt_bsshslm_2020::update( Time const& origin, const long from, const
if ( interval_step == 0 )
{
erase_used_firing_rate_reg_history();
erase_used_update_history();
erase_used_eprop_history();

if ( with_reset )
Expand Down
1 change: 0 additions & 1 deletion models/eprop_iaf_bsshslm_2020.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ eprop_iaf_bsshslm_2020::update( Time const& origin, const long from, const long
if ( interval_step == 0 )
{
erase_used_firing_rate_reg_history();
erase_used_update_history();
erase_used_eprop_history();

if ( with_reset )
Expand Down
1 change: 0 additions & 1 deletion models/eprop_readout_bsshslm_2020.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ eprop_readout_bsshslm_2020::update( Time const& origin, const long from, const l

if ( interval_step == 0 )
{
erase_used_update_history();
erase_used_eprop_history();

if ( with_reset )
Expand Down
5 changes: 0 additions & 5 deletions nestkernel/eprop_archiving_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ class EpropArchivingNode : public Node
//! Get an iterator pointing to the eprop history entry of the given time step.
typename std::vector< HistEntryT >::iterator get_eprop_history( const long time_step );

/**
* Erase update history parts for which the access counter has decreased to zero since no synapse needs them any
* longer.
*/
void erase_used_update_history();

/**
* Erase e-prop history entries corresponding to update intervals during which no spikes were transmitted to target
Expand Down
28 changes: 4 additions & 24 deletions nestkernel/eprop_archiving_node_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ EpropArchivingNode< HistEntryT >::write_update_to_history( const long t_previous
{
// If an entry exists for the previous update time, decrement its access counter
--it_hist_prev->access_counter_;
}

if ( not is_bsshslm_2020_model )
{
erase_used_update_history();
if ( it_hist_prev->access_counter_ == 0 )
{
update_history_.erase( it_hist_prev );
}
}
}

Expand Down Expand Up @@ -186,25 +185,6 @@ EpropArchivingNode< HistEntryT >::erase_used_eprop_history( const long eprop_isi
eprop_history_.erase( it_eprop_hist_from_2, it_eprop_hist_to_2 ); // erase found entries since no longer used
}

template < typename HistEntryT >
void
EpropArchivingNode< HistEntryT >::erase_used_update_history()
{
auto it_hist = update_history_.begin();
while ( it_hist != update_history_.end() )
{
if ( it_hist->access_counter_ == 0 )
{
// erase() invalidates the iterator, but returns a new, valid iterator
it_hist = update_history_.erase( it_hist );
}
else
{
++it_hist;
}
}
}

} // namespace nest

#endif // EPROP_ARCHIVING_NODE_IMPL_H

0 comments on commit e5446be

Please sign in to comment.