| 367 | self.w_down = None |
| 368 | |
| 369 | def forward(self, hidden_states: torch.Tensor, scale: float = 1.0) -> torch.Tensor: |
| 370 | if self.padding_mode != "zeros": |
| 371 | hidden_states = F.pad(hidden_states, self._reversed_padding_repeated_twice, mode=self.padding_mode) |
| 372 | padding = (0, 0) |
| 373 | else: |
| 374 | padding = self.padding |
| 375 | |
| 376 | original_outputs = F.conv2d( |
| 377 | hidden_states, self.weight, self.bias, self.stride, padding, self.dilation, self.groups |
| 378 | ) |
| 379 | |
| 380 | if self.lora_layer is None: |
| 381 | return original_outputs |
| 382 | else: |
| 383 | return original_outputs + (scale * self.lora_layer(hidden_states)) |
| 384 | |
| 385 | |
| 386 | class LoRACompatibleLinear(nn.Linear): |