Merge pull request #43746 from trentlo:clear_opnds_for_removed_hlos
PiperOrigin-RevId: 335915793 Change-Id: I938fe587a47dc425d2ed6e227c0b938981039e62
This commit is contained in:
commit
6f2bb31b57
@ -315,6 +315,8 @@ Status HloComputation::RemoveInstructionImpl(HloInstruction* instruction,
|
||||
(*inst_it->second)->set_parent(nullptr);
|
||||
to_be_deleted_.emplace_back(inst_it->second->release());
|
||||
to_be_deleted_.back()->DetachFromOperandsAndUsers();
|
||||
// Clear all operands to avoid Null operands.
|
||||
to_be_deleted_.back()->RemoveAllOperands();
|
||||
to_be_deleted_.back()->MarkAsDead();
|
||||
instructions_.erase(inst_it->second);
|
||||
instruction_iterators_.erase(inst_it);
|
||||
|
||||
@ -1911,6 +1911,8 @@ class HloInstruction {
|
||||
// by factory methods.
|
||||
HloInstruction(HloOpcode opcode, const Shape& shape);
|
||||
|
||||
void RemoveAllOperands() { operands_.clear(); }
|
||||
|
||||
void RemoveOperandAt(int index) {
|
||||
operands_.erase(operands_.begin() + index);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user