(self, inp, out)
| 26 | self.nsamples = 0 |
| 27 | |
| 28 | def add_batch(self, inp, out): |
| 29 | if len(inp.shape) == 2: |
| 30 | inp = inp.unsqueeze(0) |
| 31 | tmp = inp.shape[0] |
| 32 | if isinstance(self.layer, nn.Linear) or isinstance( |
| 33 | self.layer, transformers.Conv1D |
| 34 | ): |
| 35 | if len(inp.shape) == 3: |
| 36 | inp = inp.reshape((-1, inp.shape[-1])) |
| 37 | inp = inp.t() |
| 38 | self.H *= self.nsamples / (self.nsamples + tmp) |
| 39 | self.nsamples += tmp |
| 40 | inp = math.sqrt(2 / self.nsamples) * inp.float() |
| 41 | self.H += inp.matmul(inp.t()) |
| 42 | |
| 43 | def fasterprune(self, sparsity, prune_n=0, prune_m=0, blocksize=128, percdamp=0.01): |
| 44 | W = self.layer.weight.data.clone() |
nothing calls this directly
no outgoing calls
no test coverage detected