| 767 | } |
| 768 | |
| 769 | Status AlgebraicSimplifierVisitor::HandleCopy(HloInstruction* copy) { |
| 770 | // If a copy feeds a copy, make it a single copy. |
| 771 | HloInstruction* op; |
| 772 | if (Match(copy, m::Copy(m::Copy(m::Op(&op))))) { |
| 773 | return ReplaceWithNewInstruction( |
| 774 | copy, HloInstruction::CreateUnary(copy->shape(), HloOpcode::kCopy, op)); |
| 775 | } |
| 776 | // All copies can be eliminated (assuming layout constraints are satisfied). |
| 777 | if (ReplaceInstructionIfSameShape(copy, copy->mutable_operand(0))) { |
| 778 | return Status::OK(); |
| 779 | } |
| 780 | |
| 781 | if (HloInstruction* bitcast_operand = |
| 782 | BitcastingOperandOfReshapeOrCopyChain(copy, options_)) { |
| 783 | ReplaceWithBitcast(copy, bitcast_operand); |
| 784 | return Status::OK(); |
| 785 | } |
| 786 | |
| 787 | // Replace Copy(Reshape()) with Reshape() if the Reshape is a logical bitcast. |
| 788 | if (copy->operand(0)->opcode() == HloOpcode::kReshape && |
| 789 | copy->operand(0)->user_count() == 1 && |
| 790 | ShapeUtil::ReshapeIsBitcast(copy->operand(0)->shape(), copy->shape())) { |
| 791 | return ReplaceWithNewInstruction( |
| 792 | copy, |
| 793 | copy->operand(0)->CloneWithNewOperands( |
| 794 | copy->shape(), {copy->mutable_operand(0)->mutable_operand(0)})); |
| 795 | } |
| 796 | return Status::OK(); |
| 797 | } |
| 798 | |
| 799 | Status AlgebraicSimplifierVisitor::HandleConcatenate( |
| 800 | HloInstruction* concatenate) { |
nothing calls this directly
no test coverage detected