utils
GatherLayer
Bases: Function
Source code in meds_torch/models/utils.py
backward(ctx, grad_output)
staticmethod
Handles backpropagation for the all_gather operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grad_output |
Tensor
|
Gradients passed from the next layer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Tensor |
Gradient for the local portion of the tensor. |
Source code in meds_torch/models/utils.py
forward(ctx, tensor)
staticmethod
Performs an all_gather operation that allows gradients to flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensor |
Tensor
|
The tensor to gather from all devices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Tensor |
Concatenated tensor from all devices. |