ContextManager for creating hierarchical name scopes.
(name)
| 1641 | # TODO(agarwal): get rid of this and use ops.name_scope instead. |
| 1642 | @contextlib.contextmanager |
| 1643 | def namescope(name): |
| 1644 | """ContextManager for creating hierarchical name scopes.""" |
| 1645 | ctx = context() |
| 1646 | old_name = ctx.scope_name |
| 1647 | ctx.scope_name = "%s/%s" % (old_name, name) if old_name else name |
| 1648 | try: |
| 1649 | yield |
| 1650 | finally: |
| 1651 | ctx.scope_name = old_name |
| 1652 | |
| 1653 | |
| 1654 | def scope_name(): |