Forward pass.
(ctx: Any, group: dist.ProcessGroup, input: torch.Tensor, weight, bias, training: bool)
| 265 | |
| 266 | @staticmethod |
| 267 | def forward(ctx: Any, group: dist.ProcessGroup, input: torch.Tensor, weight, bias, training: bool) -> torch.Tensor: |
| 268 | """ |
| 269 | Forward pass. |
| 270 | """ |
| 271 | ctx.use_bias = bias is not None |
| 272 | ctx.group = group |
| 273 | output = torch.matmul(input, weight.transpose(-1, -2)) |
| 274 | if bias is not None: |
| 275 | output = add_bias(output, bias, training) |
| 276 | |
| 277 | ctx.save_for_backward(input, weight) |
| 278 | |
| 279 | return output |
| 280 | |
| 281 | @staticmethod |
| 282 | def backward(ctx: Any, grad_output: torch.Tensor) -> Tuple[None, torch.Tensor]: |