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

Class Catcher

lib/prune.py:110–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 cache = {"i": 0, "attention_mask": None, "position_ids": None}
109
110 class Catcher(nn.Module):
111 def __init__(self, module):
112 super().__init__()
113 self.module = module
114
115 def forward(self, inp, **kwargs):
116 inps.append(inp)
117 attention_mask.append(kwargs["attention_mask"])
118 position_ids.append(kwargs["position_ids"])
119 # inps[cache['i']] = inp
120 # cache['i'] += 1
121 # cache['attention_mask'] = kwargs['attention_mask']
122 # cache['position_ids'] = kwargs['position_ids']
123 raise ValueError
124
125 layers[0] = Catcher(layers[0])
126 for batch in dataloader:

Callers 3

prune_sparsegptFunction · 0.85
prune_ablateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected