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

Function NameScope

caffe2/python/scope.py:36–52  ·  view source on GitHub ↗
(prefix, reset=False)

Source from the content-addressed store, hash-verified

34
35@contextlib.contextmanager
36def NameScope(prefix, reset=False):
37 global _threadlocal_scope
38 assert isinstance(prefix, basestring) or prefix is None, \
39 "NameScope takes in a string as its argument."
40 old_scope = CurrentNameScope()
41 prefix = prefix + _NAMESCOPE_SEPARATOR if prefix else ''
42 if reset:
43 _threadlocal_scope.namescope = prefix
44 else:
45 _threadlocal_scope.namescope = _threadlocal_scope.namescope + prefix
46
47 try:
48 yield
49 finally:
50 assert _threadlocal_scope.namescope.endswith(prefix), \
51 "The namescope variable is changed from outside NameScope() calls."
52 _threadlocal_scope.namescope = old_scope
53
54
55@contextlib.contextmanager

Callers 1

set_input_recordMethod · 0.85

Calls 2

isinstanceFunction · 0.85
CurrentNameScopeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…