MCPcopy Index your code
hub / github.com/pytorch/pytorch / Cluster

Class Cluster

caffe2/python/task.py:21–51  ·  view source on GitHub ↗

Context that keeps track of all the node names used. Users shouldn't have to use them directly, since a Cluster is automatically generated at the first usage of 'Node'.

Source from the content-addressed store, hash-verified

19
20
21class Cluster(context.DefaultManaged):
22 """
23 Context that keeps track of all the node names used.
24 Users shouldn't have to use them directly, since a Cluster is automatically
25 generated at the first usage of 'Node'.
26 """
27
28 def __init__(self):
29 # list instead of set to keep order
30 self._nodes = []
31 self._node_kwargs = {}
32
33 def add_node(self, node):
34 if str(node) not in self._nodes:
35 self._nodes.append(str(node))
36 self._node_kwargs[str(node)] = _merge_node_kwargs(
37 node.kwargs(),
38 self._node_kwargs.get(str(node)))
39
40 def nodes(self):
41 """
42 Returns the list of unique node names used within this context.
43 """
44 return self._nodes
45
46 def node_kwargs(self):
47 return self._node_kwargs
48
49 def __repr__(self):
50 return "Cluster(nodes={}, node_kwargs={})".format(
51 self.nodes(), self.node_kwargs())
52
53
54class Node(context.DefaultManaged):

Callers 6

run_withMethod · 0.90
build_cache_stepMethod · 0.90
_compile_task_groupMethod · 0.90

Calls

no outgoing calls

Tested by 4

run_withMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…