diff options
author | Mark Heffernan <meheff@google.com> | 2017-03-10 16:20:53 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-03-10 16:50:20 -0800 |
commit | fc112a6b53d782eacb46eb357a8720d6b5a5d3cc (patch) | |
tree | 0810b24667fc9a08aaa270252931d66c64fee87d /tensorflow/compiler/xla/service/hlo_computation.cc | |
parent | eb8bb9e461f669f299aa031634530995bc43f92b (diff) |
[XLA] Replace uses of std::set with std::vector.
std::set is slow and the iteration order is unstable. A couple other opportunistic changes include consolidating all called computations of an instruction in a single vector. This faciliates fast access to all called computations. Also, replace AddControlSuccessor/Predecessor with Add/RemoveControlDepedencyTo which is less error prone as you can't create a half connected control edge.
Change: 149810889
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_computation.cc')
-rw-r--r-- | tensorflow/compiler/xla/service/hlo_computation.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc index 366ecb5a52..c47b49a0c6 100644 --- a/tensorflow/compiler/xla/service/hlo_computation.cc +++ b/tensorflow/compiler/xla/service/hlo_computation.cc @@ -142,6 +142,12 @@ Status HloComputation::RemoveInstruction(HloInstruction* instruction) { TF_RET_CHECK(instruction->user_count() == 0) << "instruction " << instruction->name() << " has users and cannot be removed"; + TF_RET_CHECK(instruction->control_predecessors().empty()) + << "instruction " << instruction->name() + << " has control predecessors and cannot be removed"; + TF_RET_CHECK(instruction->control_successors().empty()) + << "instruction " << instruction->name() + << " has control successors and cannot be removed"; TF_RET_CHECK(instruction_iterators_.count(instruction) != 0); auto inst_it = instruction_iterators_.at(instruction); @@ -227,7 +233,8 @@ void ComputeComputationPostOrder( } for (auto& instruction : computation->instructions()) { - for (auto& called_computation : instruction->MakeCalledComputationsSet()) { + for (HloComputation* called_computation : + instruction->called_computations()) { ComputeComputationPostOrder(called_computation, visited, post_order); } } @@ -383,15 +390,6 @@ StatusOr<HloInstruction*> HloComputation::DeepCopyInstruction( } } -Status HloComputation::AddControlDependency(HloInstruction* predecessor, - HloInstruction* successor) { - TF_RET_CHECK(instruction_iterators_.count(predecessor) > 0); - TF_RET_CHECK(instruction_iterators_.count(successor) > 0); - successor->AddControlPredecessor(predecessor); - predecessor->AddControlSuccessor(successor); - return Status::OK(); -} - ProgramShape HloComputation::ComputeProgramShape() const { ProgramShape program_shape; |