[Tensorflow Metrics] Add tracking for enable_control_flow() and disable_control_flow() usage.

PiperOrigin-RevId: 304501441
Change-Id: Ic4107d97db6c93d35ac4eb7257d24f62af3cd012
This commit is contained in:
A. Unique TensorFlower 2020-04-02 16:29:21 -07:00 committed by TensorFlower Gardener
parent 4455956ce8
commit 09f552a0c2
2 changed files with 7 additions and 1 deletions

View File

@ -91,7 +91,9 @@ _USE_C_SHAPES = True
_api_usage_gauge = monitoring.BoolGauge(
"/tensorflow/api/ops_eager_execution",
"Whether ops.enable_eager_execution() is called.")
_control_flow_api_gauge = monitoring.BoolGauge(
"/tensorflow/api/enable_control_flow_v2",
"Whether enable_control_flow_v2() is called.")
# pylint: disable=protected-access
_DTYPES_INTERN_TABLE = dtypes._INTERN_TABLE

View File

@ -42,6 +42,8 @@ def enable_control_flow_v2(): # pylint: disable=invalid-name
Note: v2 control flow is always enabled inside of tf.function. Calling this
function is not required.
"""
# pylint: disable=protected-access
ops._control_flow_api_gauge.get_cell().set(True)
control_flow_util.ENABLE_CONTROL_FLOW_V2 = True
@ -55,6 +57,8 @@ def disable_control_flow_v2(): # pylint: disable=invalid-name
If your code needs tf.disable_control_flow_v2() to be called to work
properly please file a bug.
"""
# pylint: disable=protected-access
ops._control_flow_api_gauge.get_cell().set(False)
control_flow_util.ENABLE_CONTROL_FLOW_V2 = False