Skip to content

Commit 987c371

Browse files
should_record_summaries() should return false is no summary writer has been
set. PiperOrigin-RevId: 278012879 Change-Id: I605feca5f912cabf053705bf2f5374a5226c7f21
1 parent 2df5ec1 commit 987c371

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tensorflow/python/ops/summary_ops_v2.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,21 @@ def __init__(self):
7878
def _should_record_summaries_internal(default_state):
7979
"""Returns boolean Tensor if summaries should/shouldn't be recorded.
8080
81-
Now the summary condition is decided by logical "and" of two conditions:
82-
ctx.summary_recording and ctx.summary_recording_distribution_strategy. The
83-
former one is usually set by user, and the latter one is controlled by
84-
DistributionStrategy (tf.distribute.ReplicaContext).
81+
Now the summary condition is decided by logical "and" of below conditions:
82+
First, summary writer must be set. Given this constraint is met,
83+
ctx.summary_recording and ctx.summary_recording_distribution_strategy.
84+
The former one is usually set by user, and the latter one is controlled
85+
by DistributionStrategy (tf.distribute.ReplicaContext).
8586
8687
Args:
87-
default_state: can be True or False. The default summary behavior when user
88-
does not specify ctx.summary_recording and
89-
ctx.summary_recording_distribution_strategy is True.
88+
default_state: can be True or False. The default summary behavior when
89+
summary writer is set and the user does not specify
90+
ctx.summary_recording and ctx.summary_recording_distribution_strategy
91+
is True.
9092
"""
93+
if _summary_state.writer is None:
94+
return constant_op.constant(False)
95+
9196
resolve = lambda x: x() if callable(x) else x
9297
cond_distributed = resolve(_summary_state.is_recording_distribution_strategy)
9398
cond = resolve(_summary_state.is_recording)

0 commit comments

Comments
 (0)