MCPcopy Create free account
hub / github.com/boyiwei/alignment-attribution-code / forward

Method forward

lib/model_wrapper_low.py:31–42  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

29 self.activation_norms = []
30
31 def forward(self, x):
32 if self.record_activation:
33 if hasattr(self, "mask") and self.mask is not None:
34 x_ = x[self.mask] # num * dim
35 else:
36 x_ = x # bs * seq_len * dim
37 self.activation_norms.append(
38 x_.view(-1, x_.shape[-1]).cpu()
39 ) # offload to CPU.
40
41 out = self.base(x)
42 return out
43
44
45class no_act_recording:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected