Exposes should_record_summaries() and optimizes for static record_if values.

PiperOrigin-RevId: 307890325
Change-Id: Ide4b37d8ccefc9729b60e42239e1774e8fc93bb0
This commit is contained in:
A. Unique TensorFlower 2020-04-22 13:48:36 -07:00 committed by TensorFlower Gardener
parent 5328a92d9d
commit 5a07c487f6
2 changed files with 10 additions and 0 deletions
tensorflow
python/ops
tools/api/golden/v2

View File

@ -93,6 +93,11 @@ def _should_record_summaries_internal(default_state):
if _summary_state.writer is None:
return constant_op.constant(False)
if not callable(_summary_state.is_recording):
static_cond = tensor_util.constant_value(_summary_state.is_recording)
if static_cond is not None and not static_cond:
return constant_op.constant(False)
resolve = lambda x: x() if callable(x) else x
cond_distributed = resolve(_summary_state.is_recording_distribution_strategy)
cond = resolve(_summary_state.is_recording)
@ -110,6 +115,7 @@ def _should_record_summaries_v2():
return _should_record_summaries_internal(default_state=True)
@tf_export("summary.should_record_summaries", v1=[])
def should_record_summaries():
"""Returns boolean Tensor which is true if summaries should be recorded."""
return _should_record_summaries_internal(default_state=False)

View File

@ -40,6 +40,10 @@ tf_module {
name: "scalar"
argspec: "args=[\'name\', \'data\', \'step\', \'description\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], "
}
member_method {
name: "should_record_summaries"
argspec: "args=[], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "text"
argspec: "args=[\'name\', \'data\', \'step\', \'description\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], "