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

Method __init__

lib/sparsegpt.py:15–26  ·  view source on GitHub ↗
(self, layer)

Source from the content-addressed store, hash-verified

13class SparseGPT:
14
15 def __init__(self, layer):
16 self.layer = layer
17 self.dev = self.layer.weight.device
18 W = layer.weight.data.clone()
19 if isinstance(self.layer, nn.Conv2d):
20 W = W.flatten(1)
21 if isinstance(self.layer, transformers.Conv1D):
22 W = W.t()
23 self.rows = W.shape[0]
24 self.columns = W.shape[1]
25 self.H = torch.zeros((self.columns, self.columns), device=self.dev)
26 self.nsamples = 0
27
28 def add_batch(self, inp, out):
29 if len(inp.shape) == 2:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected