MCPcopy Create free account
hub / github.com/BICLab/SpikingBrain-7B / dynamic_spikes

Function dynamic_spikes

W8ASpike/quant_linear.py:11–19  ·  view source on GitHub ↗
(x, k=3.0)

Source from the content-addressed store, hash-verified

9 spike_is_available = False
10
11def dynamic_spikes(x, k=3.0):
12 vth = x.abs().mean([-1], keepdim=True).float() / k
13 vth = vth.clamp(min=1e-5, max=1e4)
14 spikes_int = (x / vth).round()
15
16 if spike_is_available:
17 spikes_int = spike_fake_quant(spikes_int, lif_quantizer=SpikeCountBitwiseNode(is_bidirectional=True))
18
19 return spikes_int, vth
20
21class QuantLinear(nn.Linear):
22 def __init__(self, in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, w_group_size=128, dynamic_sfr=3.0):

Callers 2

forwardMethod · 0.85
forwardMethod · 0.85

Calls 2

spike_fake_quantFunction · 0.85

Tested by

no test coverage detected