MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / forward

Method forward

deepspeed/module_inject/layers.py:263–275  ·  view source on GitHub ↗

Forward pass.

(ctx: Any, group: dist.ProcessGroup, input: torch.Tensor, weight, bias, training: bool)

Source from the content-addressed store, hash-verified

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]:

Callers

nothing calls this directly

Calls 2

add_biasFunction · 0.85
transposeMethod · 0.45

Tested by

no test coverage detected