From 63008254491e19dbab1480dab9e64d99e498bc84 Mon Sep 17 00:00:00 2001 From: Mangpo Phothilimthana Date: Mon, 6 Jul 2020 20:51:01 -0700 Subject: [PATCH] Fix fingerprint mismatch issue by excluding module's and entry computation's name when computing fingerprint. PiperOrigin-RevId: 319911247 Change-Id: Id8ced870114fcbfd26e7ef1d4fd2589d85b5d06b --- tensorflow/compiler/xla/service/hlo_computation.cc | 6 +++++- tensorflow/compiler/xla/service/hlo_module.cc | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc index 4b86a58c35c..f05c0e77c93 100644 --- a/tensorflow/compiler/xla/service/hlo_computation.cc +++ b/tensorflow/compiler/xla/service/hlo_computation.cc @@ -549,7 +549,11 @@ string HloComputation::ToString( if (options.print_percent()) { s << "%"; } - s << PrintName(name(), options.print_ids()) << " "; + if (options.print_ids() || !IsEntryComputation()) { + // Exclude entry computation's name because it includes and leads to + // non-deterministic fingerprint. + s << PrintName(name(), options.print_ids()) << " "; + } } if (options.print_program_shape()) { diff --git a/tensorflow/compiler/xla/service/hlo_module.cc b/tensorflow/compiler/xla/service/hlo_module.cc index 220443d5276..c0b733c19cd 100644 --- a/tensorflow/compiler/xla/service/hlo_module.cc +++ b/tensorflow/compiler/xla/service/hlo_module.cc @@ -230,7 +230,10 @@ void HloModule::ReplaceComputations( string HloModule::ToString(const HloPrintOptions& options) const { std::ostringstream s; - s << "HloModule " << PrintName(name(), options.print_ids()); + // When print_ids() is false, exclude module's name because it includes and + // leads to non-deterministic fingerprint. + s << "HloModule " + << (options.print_ids() ? PrintName(name(), options.print_ids()) : ""); if (has_schedule()) { TF_CHECK_OK(schedule().Verify()); s << ", is_scheduled=true";