From 87d8055c74a65ec9fb2a13f38e6e2c5d30b7e2e4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 9 Oct 2018 09:30:32 -0700 Subject: Correctly pre-reserve visit state in HloInstruction::PostOrderDFS Previously we pre-reserverd the visit state based on the number of instructions but then started to index it with the instruction unique ID what can be larger then the instruction count. This resulted in some very expensive re-allocations what can be eliminated by reserving the correctly sized buffer. PiperOrigin-RevId: 216369849 --- tensorflow/compiler/xla/service/hlo_instruction.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/compiler/xla/service/hlo_instruction.cc b/tensorflow/compiler/xla/service/hlo_instruction.cc index 5c3908a9a4..050d28b289 100644 --- a/tensorflow/compiler/xla/service/hlo_instruction.cc +++ b/tensorflow/compiler/xla/service/hlo_instruction.cc @@ -2474,7 +2474,7 @@ template static Status PostOrderDFS(HloInstruction* root, Visitor* visitor, const InternalCompareFunction* operand_order, bool ignore_control_predecessors) { - visitor->ReserveVisitStates(root->GetModule()->instruction_count()); + visitor->ReserveVisitStates(root->GetModule()->NumUniqueInstructionIds()); // dfs_stack holds pairs of unique_id(), HloInstruction*>. // -- cgit v1.2.3