MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / write_raw_pb

Function write_raw_pb

tensorflow/python/ops/summary_ops_v2.py:653–701  ·  view source on GitHub ↗

Writes a summary using raw `tf.compat.v1.Summary` protocol buffers. Experimental: this exists to support the usage of V1-style manual summary writing (via the construction of a `tf.compat.v1.Summary` protocol buffer) with the V2 summary writing API. Args: tensor: the string Tensor hold

(tensor, step=None, name=None)

Source from the content-addressed store, hash-verified

651
652@tf_export("summary.experimental.write_raw_pb", v1=[])
653def write_raw_pb(tensor, step=None, name=None):
654 """Writes a summary using raw `tf.compat.v1.Summary` protocol buffers.
655
656 Experimental: this exists to support the usage of V1-style manual summary
657 writing (via the construction of a `tf.compat.v1.Summary` protocol buffer)
658 with the V2 summary writing API.
659
660 Args:
661 tensor: the string Tensor holding one or more serialized `Summary` protobufs
662 step: Explicit `int64`-castable monotonic step value for this summary. If
663 omitted, this defaults to `tf.summary.experimental.get_step()`, which must
664 not be None.
665 name: Optional string name for this op.
666
667 Returns:
668 True on success, or false if no summary was written because no default
669 summary writer was available.
670
671 Raises:
672 ValueError: if a default writer exists, but no step was provided and
673 `tf.summary.experimental.get_step()` is None.
674 """
675 with ops.name_scope(name, "write_raw_pb") as scope:
676 if context.context().summary_writer is None:
677 return constant_op.constant(False)
678 if step is None:
679 step = get_step()
680 if step is None:
681 raise ValueError("No step set via 'step' argument or "
682 "tf.summary.experimental.set_step()")
683
684 def record():
685 """Record the actual summary and return True."""
686 # Note the identity to move the tensor to the CPU.
687 with ops.device("cpu:0"):
688 raw_summary_op = gen_summary_ops.write_raw_proto_summary(
689 context.context().summary_writer._resource, # pylint: disable=protected-access
690 step,
691 array_ops.identity(tensor),
692 name=scope)
693 with ops.control_dependencies([raw_summary_op]):
694 return constant_op.constant(True)
695
696 with ops.device("cpu:0"):
697 op = smart_cond.smart_cond(
698 _should_record_summaries_v2(), record, _nothing, name="summary_cond")
699 if not context.executing_eagerly():
700 ops.add_to_collection(ops.GraphKeys._SUMMARY_COLLECTION, op) # pylint: disable=protected-access
701 return op
702
703
704def summary_writer_function(name, tensor, function, family=None):

Callers

nothing calls this directly

Calls 8

get_stepFunction · 0.85
executing_eagerlyMethod · 0.80
add_to_collectionMethod · 0.80
name_scopeMethod · 0.45
contextMethod · 0.45
constantMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected