Writes a tensor summary if possible.
(name, tensor, metadata=None, family=None, step=None)
| 734 | |
| 735 | |
| 736 | def generic(name, tensor, metadata=None, family=None, step=None): |
| 737 | """Writes a tensor summary if possible.""" |
| 738 | |
| 739 | def function(tag, scope): |
| 740 | if metadata is None: |
| 741 | serialized_metadata = constant_op.constant("") |
| 742 | elif hasattr(metadata, "SerializeToString"): |
| 743 | serialized_metadata = constant_op.constant(metadata.SerializeToString()) |
| 744 | else: |
| 745 | serialized_metadata = metadata |
| 746 | # Note the identity to move the tensor to the CPU. |
| 747 | return gen_summary_ops.write_summary( |
| 748 | context.context().summary_writer._resource, # pylint: disable=protected-access |
| 749 | _choose_step(step), |
| 750 | array_ops.identity(tensor), |
| 751 | tag, |
| 752 | serialized_metadata, |
| 753 | name=scope) |
| 754 | return summary_writer_function(name, tensor, function, family=family) |
| 755 | |
| 756 | |
| 757 | def scalar(name, tensor, family=None, step=None): |
nothing calls this directly
no test coverage detected