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

Method forward

deepspeed/module_inject/layers.py:267–279  ·  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

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

Callers

nothing calls this directly

Calls 2

add_biasFunction · 0.85
transposeMethod · 0.45

Tested by

no test coverage detected