From 14e27e3b9ba44e0acd3cde5a4f63067ece780417 Mon Sep 17 00:00:00 2001 From: Edward Loper Date: Sat, 2 May 2020 13:50:17 -0700 Subject: [PATCH] Make ConcreteFunction.pretty_printed_signature deterministic. PiperOrigin-RevId: 309576809 Change-Id: Iacdba60cd1d0b1d8da887bb41143e89c70bedc43 --- tensorflow/python/eager/function.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/eager/function.py b/tensorflow/python/eager/function.py index bacad8eb23b..97708f056c2 100644 --- a/tensorflow/python/eager/function.py +++ b/tensorflow/python/eager/function.py @@ -22,6 +22,7 @@ from __future__ import print_function import collections import functools import itertools +import pprint import threading import types as types_lib import weakref @@ -2221,7 +2222,8 @@ class ConcreteFunction(object): pieces = nest.flatten(spec, expand_composites=False) markers = [_Marker("<{}>".format(i + 1)) for i in range(len(pieces))] structure = nest.pack_sequence_as(spec, markers) - result = "{}".format(structure) + # Ensure dictionaries are sorted by key (for determinism) + result = pprint.pformat(structure, width=10000) for (marker, piece) in zip(markers, pieces): result += "\n {}: {}".format(marker, pretty_print_spec(piece)) return result