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

Function _count_worker

tensorflow/python/distribute/estimator_training.py:49–56  ·  view source on GitHub ↗

Counts the number of workers (including chief) in cluster_spec.

(cluster_spec, chief_task_type)

Source from the content-addressed store, hash-verified

47
48
49def _count_worker(cluster_spec, chief_task_type):
50 """Counts the number of workers (including chief) in cluster_spec."""
51 if not cluster_spec:
52 raise RuntimeError(
53 'Internal error: `_count_worker` does not expect empty cluster_spec.')
54
55 return (len(cluster_spec.as_dict().get(WORKER, [])) + len(
56 cluster_spec.as_dict().get(chief_task_type, [])))
57
58
59def _get_global_id(cluster_spec, task_type, task_id, chief_task_type):

Callers 1

Calls 2

getMethod · 0.45
as_dictMethod · 0.45

Tested by

no test coverage detected