MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / Node

Class Node

python/paddle/distributed/auto_parallel/static/graph.py:18–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class Node:
19 def __init__(self, id, **attrs):
20 # Each node must has a unique id
21 self._id = id
22 # Attributes for Node
23 self._attrs = {}
24 self._attrs.update(attrs)
25
26 @property
27 def id(self):
28 return self._id
29
30 @property
31 def attrs(self):
32 return self._attrs
33
34 def __getitem__(self, attr_name):
35 return self._attrs[attr_name]
36
37 def __setitem__(self, attr_name, attr_value):
38 self._attrs[attr_name] = attr_value
39
40 def __contains__(self, attr_name):
41 try:
42 return attr_name in self._attrs
43 except TypeError:
44 return False
45
46 def __str__(self):
47 str = f"(id: {self.id}, attrs: {self.attrs})"
48 return str
49
50
51class Edge:

Callers 2

add_nodeMethod · 0.70
add_edgeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected