r""" Args: x (\*, in_features): input tensor dx (\*, in_features): same shape as x, or can be broadcast. if None, dx = 0. Returns: y (* out_features): :math:`y = W (x + dx) + b + b0`
(self, x: torch.Tensor, dx: torch.Tensor = None)
| 361 | ) |
| 362 | |
| 363 | def forward(self, x: torch.Tensor, dx: torch.Tensor = None): |
| 364 | r""" |
| 365 | Args: |
| 366 | x (\*, in_features): |
| 367 | input tensor |
| 368 | dx (\*, in_features): |
| 369 | same shape as x, or can be broadcast. |
| 370 | if None, dx = 0. |
| 371 | |
| 372 | Returns: |
| 373 | y (* out_features): |
| 374 | :math:`y = W (x + dx) + b + b0` |
| 375 | |
| 376 | """ |
| 377 | weight = self.scale * self.weight # (cout, cin) |
| 378 | |
| 379 | if self.demodulate: |
| 380 | demod = torch.rsqrt(weight.pow(2).sum(dim=1, keepdim=True) + self.eps) # (cout, 1) |
| 381 | weight = weight * demod |
| 382 | |
| 383 | y = F.linear( |
| 384 | input=x + dx if dx is not None else x, |
| 385 | weight=self.lr_multiplier * weight, |
| 386 | bias=self.lr_multiplier * self.bias if self.bias is not None else None, |
| 387 | ) |
| 388 | |
| 389 | if self.fixed_bias is not None: |
| 390 | y = y + self.fixed_bias |
| 391 | |
| 392 | return y |
nothing calls this directly
no outgoing calls
no test coverage detected