(self, x: torch.Tensor, *args, **kwargs)
| 198 | # original only survives in the cache. |
| 199 | org_weight = self.org_weight.to(device=device, dtype=self.weight.dtype) |
| 200 | diff = self.weight.to(device) - org_weight |
| 201 | diff_b = None |
| 202 | if self.bias is not None and self.org_bias is not None: |
| 203 | org_bias = self._org_bias_tensor(device, self.bias.dtype) |
| 204 | diff_b = self.bias.to(device) - org_bias |
| 205 | if shape is not None: |
| 206 | diff = diff.view(shape) |
| 207 | if multiplier != 1: |
| 208 | diff = diff * multiplier |
| 209 | if diff_b is not None: |
| 210 | diff_b = diff_b * multiplier |
| 211 | return diff, diff_b |
| 212 | |
| 213 | def get_merged_weight(self, multiplier=1, shape=None, device=None): |
| 214 | weight, bias = self.make_weight(multiplier, device) |
| 215 | if shape is not None: |
| 216 | weight = weight.view(shape) |
| 217 | if bias is not None: |
| 218 | bias = bias.view(shape[0]) |
| 219 | return weight, bias |
| 220 | |
| 221 | def forward(self, x: torch.Tensor, *args, **kwargs): |
| 222 | dropped = bool( |
| 223 | self.module_dropout |
| 224 | and self.training |
| 225 | and torch.rand(1) < self.module_dropout |
| 226 | ) |
| 227 |
nothing calls this directly
no test coverage detected