Refactor: changing the internal name of summary_ops_v2.graph to graph_v1.

In addition, we changed `summary_ops_v2.graph_v2` to `graph`.

PiperOrigin-RevId: 342896045
Change-Id: I40ab3e87aab6501f8381c9690b465ffb3991681c
This commit is contained in:
Stephan Lee 2020-11-17 10:43:15 -08:00 committed by TensorFlower Gardener
parent 4db63bbd25
commit fbe14f3bf3
4 changed files with 13 additions and 19 deletions

View File

@ -2201,7 +2201,7 @@ class TensorBoard(Callback, version_utils.TensorBoardVersionSelector):
train_fn = self.model.train_function
# If the train_function is a `tf.function`, we can write out a graph
if hasattr(train_fn, 'function_spec'):
summary_ops_v2.graph(train_fn._concrete_stateful_fn.graph, step=0) # pylint: disable=protected-access
summary_ops_v2.graph(train_fn._concrete_stateful_fn.graph) # pylint: disable=protected-access
def _write_keras_model_summary(self):
"""Writes Keras graph network summary to TensorBoard."""

View File

@ -170,7 +170,7 @@ class TensorBoard(callbacks.TensorBoard):
self.writer = summary_ops_v2.create_file_writer_v2(self.log_dir)
if not model.run_eagerly and self.write_graph:
with self.writer.as_default():
summary_ops_v2.graph(K.get_graph(), step=0)
summary_ops_v2.graph(K.get_graph())
elif self.write_graph:
self.writer = tf_summary.FileWriter(self.log_dir, K.get_graph())
else:

View File

@ -1217,7 +1217,7 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
summary_ops.set_step(None)
@test_util.run_v2_only
def testGraphV2_graph(self):
def testGraph_graph(self):
@def_function.function
def f():
@ -1226,13 +1226,13 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
return x**y
def summary_op_fn():
summary_ops.graph_v2(f.get_concrete_function().graph)
summary_ops.graph(f.get_concrete_function().graph)
event = self.exec_summary_op(summary_op_fn)
self.assertIsNotNone(event.graph_def)
@test_util.run_v2_only
def testGraphV2_graphDef(self):
def testGraph_graphDef(self):
@def_function.function
def f():
@ -1241,15 +1241,15 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
return x**y
def summary_op_fn():
summary_ops.graph_v2(f.get_concrete_function().graph.as_graph_def())
summary_ops.graph(f.get_concrete_function().graph.as_graph_def())
event = self.exec_summary_op(summary_op_fn)
self.assertIsNotNone(event.graph_def)
@test_util.run_v2_only
def testGraphV2_invalidData(self):
def testGraph_invalidData(self):
def summary_op_fn():
summary_ops.graph_v2('hello')
summary_ops.graph('hello')
with self.assertRaisesRegex(
ValueError,
@ -1258,7 +1258,7 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
self.exec_summary_op(summary_op_fn)
@test_util.run_v2_only
def testGraphV2_fromGraphMode(self):
def testGraph_fromGraphMode(self):
@def_function.function
def f():
@ -1268,7 +1268,7 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
@def_function.function
def g(graph):
summary_ops.graph_v2(graph)
summary_ops.graph(graph)
def summary_op_fn():
graph_def = f.get_concrete_function().graph.as_graph_def(add_shapes=True)

View File

@ -451,7 +451,7 @@ def initialize(
if graph is not None:
data = _serialize_graph(graph)
x = array_ops.placeholder(dtypes.string)
session.run(_graph(x, 0), feed_dict={x: data})
session.run(graph_v1(x, 0), feed_dict={x: data})
@tf_export("summary.create_file_writer", v1=[])
@ -966,8 +966,7 @@ def audio(name, tensor, sample_rate, max_outputs, family=None, step=None):
return summary_writer_function(name, tensor, function, family=family)
# TODO(b/171925996): rename this to `graph_v1` after changing all callsites.
def graph(param, step=None, name=None):
def graph_v1(param, step=None, name=None):
"""Writes a TensorFlow graph to the summary interface.
The graph summary is, strictly speaking, not a summary. Conditions
@ -1012,13 +1011,8 @@ def graph(param, step=None, name=None):
writer._resource, _choose_step(step), tensor, name=name) # pylint: disable=protected-access
_graph = graph # for functions with a graph parameter
# TODO(b/171925996): rename this to `graph` for consistency when graph_v1 is
# renamed.
@tf_export("summary.graph", v1=[])
def graph_v2(graph_data):
def graph(graph_data):
"""Writes a TensorFlow graph summary.
Write an instance of `tf.Graph` or `tf.compat.v1.GraphDef` as summary only