MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _mode

Method _mode

tensorflow/python/eager/context.py:636–654  ·  view source on GitHub ↗

A context manager to allow setting the mode to EAGER/GRAPH.

(self, mode)

Source from the content-addressed store, hash-verified

634
635 @tf_contextlib.contextmanager
636 def _mode(self, mode):
637 """A context manager to allow setting the mode to EAGER/GRAPH."""
638 ctx = self._thread_local_data
639 old_mode = ctx.mode
640 old_is_eager = ctx.is_eager
641 ctx.mode = mode
642 ctx.is_eager = mode == EAGER_MODE
643 if mode == EAGER_MODE:
644 # Entering graph mode does not provide us with sufficient information to
645 # record a context switch; graph-based context switches are only logged
646 # when a graph is registered as the default graph.
647 self.context_switches.push(False, eager_mode, None)
648 try:
649 yield
650 finally:
651 ctx.is_eager = old_is_eager
652 ctx.mode = old_mode
653 if mode == EAGER_MODE:
654 self.context_switches.pop()
655
656 def executing_eagerly(self):
657 """Returns True if current thread has eager executing enabled."""

Callers 2

graph_modeFunction · 0.45
eager_modeFunction · 0.45

Calls 2

pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected