MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _apply_all_reduce

Function _apply_all_reduce

tensorflow/python/ops/nccl_ops.py:210–236  ·  view source on GitHub ↗

Helper function for all_* functions.

(reduction, tensors)

Source from the content-addressed store, hash-verified

208
209
210def _apply_all_reduce(reduction, tensors):
211 """Helper function for all_* functions."""
212 if not tensors:
213 raise ValueError('Must pass >0 tensors to all reduce operations')
214
215 shared_name = _get_shared_name()
216
217 def _all_reduce():
218 """Call nccl allreduce."""
219 res = []
220 for t in tensors:
221 _check_device(t)
222 with ops.device(t.device):
223 res.append(
224 gen_nccl_ops.nccl_all_reduce(
225 input=t,
226 reduction=reduction,
227 num_devices=len(tensors),
228 shared_name=shared_name))
229 return res
230
231 if context.executing_eagerly():
232 # Nccl ops will block unless they are executed concurrently such as in a
233 # graph or a defun.
234 return def_function.function(_all_reduce)()
235 else:
236 return _all_reduce()
237
238
239def _apply_reduce(reduction, tensors):

Callers 4

all_sumFunction · 0.85
all_prodFunction · 0.85
all_minFunction · 0.85
all_maxFunction · 0.85

Calls 4

_get_shared_nameFunction · 0.85
_all_reduceFunction · 0.85
executing_eagerlyMethod · 0.80
functionMethod · 0.45

Tested by

no test coverage detected