brails.processors.FoundationClassifier.csail_segmentation_tool.csail_seg.lib.nn.modules.comm module

class brails.processors.FoundationClassifier.csail_segmentation_tool.csail_seg.lib.nn.modules.comm.FutureResult

Bases: object

A thread-safe future implementation. Used only as one-to-one pipe.

get()
put(result)
class brails.processors.FoundationClassifier.csail_segmentation_tool.csail_seg.lib.nn.modules.comm.SlavePipe(identifier, queue, result)

Bases: _SlavePipeBase

Pipe for master-slave communication.

run_slave(msg)
class brails.processors.FoundationClassifier.csail_segmentation_tool.csail_seg.lib.nn.modules.comm.SyncMaster(master_callback)

Bases: object

An abstract SyncMaster object.

  • During the replication, as the data parallel will trigger an callback of each module, all slave devices should

call register(id) and obtain an SlavePipe to communicate with the master. - During the forward pass, master device invokes run_master, all messages from slave devices will be collected, and passed to a registered callback. - After receiving the messages, the master device should gather the information and determine to message passed back to each slave devices.

property nr_slaves
register_slave(identifier)

Register an slave device.

Args:

identifier: an identifier, usually is the device id.

Returns: a SlavePipe object which can be used to communicate with the master device.

run_master(master_msg)

Main entry for the master device in each forward pass. The messages were first collected from each devices (including the master device), and then an callback will be invoked to compute the message to be sent back to each devices (including the master device).

Args:

master_msg: the message that the master want to send to itself. This will be placed as the first message when calling master_callback. For detailed usage, see _SynchronizedBatchNorm for an example.

Returns: the message to be sent back to the master device.