(self, hidden_states: torch.Tensor)
| 284 | nn.init.zeros_(self.up.weight) |
| 285 | |
| 286 | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: |
| 287 | orig_dtype = hidden_states.dtype |
| 288 | dtype = self.down.weight.dtype |
| 289 | |
| 290 | down_hidden_states = self.down(hidden_states.to(dtype)) |
| 291 | up_hidden_states = self.up(down_hidden_states) |
| 292 | |
| 293 | if self.network_alpha is not None: |
| 294 | up_hidden_states *= self.network_alpha / self.rank |
| 295 | |
| 296 | return up_hidden_states.to(orig_dtype) |
| 297 | |
| 298 | |
| 299 | class LoRACompatibleConv(nn.Conv2d): |