MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / HandleCopy

Method HandleCopy

tensorflow/compiler/xla/service/algebraic_simplifier.cc:769–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769Status 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
799Status AlgebraicSimplifierVisitor::HandleConcatenate(
800 HloInstruction* concatenate) {

Callers

nothing calls this directly

Calls 10

CopyFunction · 0.85
mutable_operandMethod · 0.80
opcodeMethod · 0.80
user_countMethod · 0.80
CloneWithNewOperandsMethod · 0.80
MatchFunction · 0.70
OpFunction · 0.70
shapeMethod · 0.45
operandMethod · 0.45

Tested by

no test coverage detected