diff --git a/tensorflow/python/framework/ops.py b/tensorflow/python/framework/ops.py index c7d219aa0c7..44392d76c27 100644 --- a/tensorflow/python/framework/ops.py +++ b/tensorflow/python/framework/ops.py @@ -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 diff --git a/tensorflow/python/ops/control_flow_v2_toggles.py b/tensorflow/python/ops/control_flow_v2_toggles.py index 5b9291f7768..15db5287c45 100644 --- a/tensorflow/python/ops/control_flow_v2_toggles.py +++ b/tensorflow/python/ops/control_flow_v2_toggles.py @@ -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