braintools.trainer.all_reduce#
- braintools.trainer.all_reduce(tensor, op='mean', axis_name='batch')[source]#
All-reduce tensor across devices.
- Parameters:
- Returns:
Reduced tensor.
- Return type:
Examples
>>> @functools.partial(jax.pmap, axis_name='batch') ... def parallel_fn(x): ... return all_reduce(x, op='mean', axis_name='batch')