(self, x: torch.Tensor)
| 487 | self.eps = getattr(original, "eps", 1e-6) |
| 488 | |
| 489 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 490 | orig_shape = x.shape |
| 491 | if x.dim() > 2: |
| 492 | x_2d = x.reshape(-1, x.shape[-1]) |
| 493 | else: |
| 494 | x_2d = x |
| 495 | |
| 496 | if self.weight is not None: |
| 497 | try: |
| 498 | out = self.kernel_fn(x_2d, self.weight, self.eps) |
| 499 | except TypeError: |
| 500 | out = self.kernel_fn(x_2d, self.weight) |
| 501 | else: |
| 502 | out = self.kernel_fn(x_2d) |
| 503 | |
| 504 | if len(orig_shape) > 2: |
| 505 | out = out.reshape(orig_shape) |
| 506 | |
| 507 | return out |
| 508 | |
| 509 | |
| 510 | class OptimizedModelContext: |
nothing calls this directly
no outgoing calls
no test coverage detected