Skip to content

Commit

Permalink
more efficient synapse implementation (#171)
Browse files Browse the repository at this point in the history
more efficient synapse implementation
  • Loading branch information
chaoming0625 authored Apr 19, 2022
2 parents 907435a + 36246c7 commit 23bba33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions brainpy/dyn/synapses/abstract_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ def update(self, _t, _dt):
post_vs = post_vs - pre_spike
post_vs = self.g_max * post_vs
else:
post_vs = bm.expand_dims(pre_spike, 1) * self.g_max
post_vs = post_vs.sum(axis=0)
post_vs = pre_spike @ self.g_max
elif isinstance(self.conn, One2One):
post_vs = pre_spike * self.g_max
else:
Expand Down Expand Up @@ -667,8 +666,7 @@ def update(self, _t, _dt):
post_vs = post_vs - self.g
post_vs = self.g_max * post_vs
else:
post_vs = bm.expand_dims(self.g, 1) * self.g_max
post_vs = post_vs.sum(axis=0)
post_vs = self.g @ self.g_max
elif isinstance(self.conn, One2One):
post_vs = self.g_max * self.g
else:
Expand Down Expand Up @@ -1230,8 +1228,7 @@ def update(self, _t, _dt):
if not self.conn.include_self:
post_g = post_g - self.g
else:
post_g = bm.expand_dims(self.g, 1) * self.g_max
post_g = post_g.sum(axis=0)
post_g = self.g * self.g_max
elif isinstance(self.conn, One2One):
post_g = self.g_max * self.g
else:
Expand Down
3 changes: 1 addition & 2 deletions brainpy/dyn/synapses/biological_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ def update(self, _t, _dt):
if not self.conn.include_self:
post_g = post_g - self.g
else:
post_g = bm.expand_dims(self.g, 1) * self.g_max
post_g = post_g.sum(axis=0)
post_g = self.g @ self.g_max
else:
if self.conn_type == 'sparse':
post_g = bm.pre2post_sum(self.g, self.post.num, self.post_ids, self.pre_ids)
Expand Down

0 comments on commit 23bba33

Please sign in to comment.