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