HLO hash function considers all instructions in the order returned by MakeComputationSortedByContent to ignore the difference from naming.

PiperOrigin-RevId: 297893716
Change-Id: I57c109c87f9168c372081c5b17598e8f6e0536ad
This commit is contained in:
A. Unique TensorFlower 2020-02-28 11:45:39 -08:00 committed by TensorFlower Gardener
parent b12869642a
commit 956b1ec099
2 changed files with 8 additions and 5 deletions

View File

@ -717,7 +717,10 @@ HloComputation* HloModule::GetComputationWithName(absl::string_view name) {
uint64 HloModule::Hash() const {
uint64 result = entry_computation_layout().Hash();
for (auto* computation : MakeComputationPostOrder()) {
// Use MakeComputationSortedByContent() instead of MakeComputationPostOrder()
// because naming may affect the order of MakeComputationPostOrder() but not
// MakeComputationSortedByContent().
for (auto* computation : MakeComputationSortedByContent()) {
for (auto* instruction : computation->MakeInstructionPostOrder()) {
result = tensorflow::Hash64Combine(result, instruction->Hash());
}

View File

@ -196,6 +196,10 @@ class HloModule {
// computation B, then A will appear after B in the sort.
std::vector<HloComputation*> MakeComputationPostOrder() const;
// Same as MakeComputationPostOrder() but sorting the computations by their
// contents.
std::vector<HloComputation*> MakeComputationSortedByContent() const;
// Gets the computations in this module which aren't for fusion nodes.
//
// Postcondition: All computations in the returned list have
@ -346,10 +350,6 @@ class HloModule {
std::unique_ptr<HloComputation> computation, bool is_entry,
bool uniquify_identifiers);
// Same as MakeComputationPostOrder() but sorting the computations by their
// contents.
std::vector<HloComputation*> MakeComputationSortedByContent() const;
string name_;
HloModuleConfig config_;
HloComputation* entry_computation_ = nullptr;