MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _Broadcast

Class _Broadcast

imperative/python/megengine/distributed/functional.py:184–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182
183
184class _Broadcast(Function):
185 def __init__(self, group=WORLD, device=None):
186 self.group = group
187 self.out_device = device
188
189 def forward(self, data):
190 self.in_device = str(data.device)
191 return collective_comm(
192 data, CollectiveComm.Mode.BROADCAST, self.group, self.out_device,
193 )
194
195 def backward(self, grad):
196 # TODO backward with a part of grad
197 if grad is not None:
198 return reduce_sum(grad, self.group, self.in_device)
199
200
201def broadcast(

Callers 1

broadcastFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected