Add tfstreamz for context and session creation in python.

PiperOrigin-RevId: 261724525
This commit is contained in:
A. Unique TensorFlower 2019-08-05 11:08:50 -07:00 committed by TensorFlower Gardener
parent 33febd68b5
commit 49d23307d5
2 changed files with 11 additions and 0 deletions
tensorflow/python

View File

@ -29,6 +29,7 @@ from tensorflow.core.protobuf import config_pb2
from tensorflow.core.protobuf import rewriter_config_pb2
from tensorflow.python import pywrap_tensorflow as tf_session
from tensorflow.python.eager import context
from tensorflow.python.eager import monitoring
from tensorflow.python.framework import device
from tensorflow.python.framework import error_interpolation
from tensorflow.python.framework import errors
@ -43,6 +44,9 @@ from tensorflow.python.util import object_identity
from tensorflow.python.util.tf_export import tf_export
from tensorflow.python.util.compat import collections_abc
_python_session_create_counter = monitoring.Counter(
'/tensorflow/api/python/session_create_counter',
'Counter for number of sessions created in Python.')
class SessionInterface(object):
"""Base class for implementations of TensorFlow client sessions."""
@ -641,6 +645,7 @@ class BaseSession(SessionInterface):
creating the TensorFlow session.
TypeError: If one of the arguments has the wrong type.
"""
_python_session_create_counter.get_cell().increase_by(1)
if graph is None:
self._graph = ops.get_default_graph()
else:

View File

@ -68,6 +68,10 @@ MIRRORING_ALL = pywrap_tensorflow.TFE_MIRRORING_ALL
_tf2_gauge = monitoring.BoolGauge("/tensorflow/api/tf2_enable",
"Whether tf2.enable() is called.")
_python_eager_context_create_counter = monitoring.Counter(
"/tensorflow/api/python/eager_context_create_counter",
"Counter for number of eager contexts created in Python.")
_tf2_gauge.get_cell().set(tf2.enabled())
@ -414,6 +418,8 @@ class Context(object):
self._log_device_placement = None
self._optimizer_experimental_options = {}
_python_eager_context_create_counter.get_cell().increase_by(1)
# pylint: enable=redefined-outer-name
def _set_global_seed(self, seed):