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

Class NameScope

python/paddle/base/framework.py:1223–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1221
1222
1223class NameScope:
1224 def __init__(self, name="", parent=None):
1225 self._children = {}
1226 self._name = name
1227 self._parent = parent
1228
1229 def child(self, prefix):
1230 if prefix not in self._children:
1231 new_child = NameScope(prefix, self)
1232 self._children[prefix] = [new_child]
1233 else:
1234 new_child = NameScope(
1235 f"{prefix}_{len(self._children[prefix])}", self
1236 )
1237 self._children[prefix].append(new_child)
1238 return new_child
1239
1240 def parent(self):
1241 return self._parent
1242
1243 def name(self):
1244 return self._name
1245
1246
1247_name_scope = NameScope()

Callers 2

childMethod · 0.70
framework.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected