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

Method HandleAnd

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

Source from the content-addressed store, hash-verified

710}
711
712Status AlgebraicSimplifierVisitor::HandleAnd(HloInstruction* logical_and) {
713 HloInstruction *lhs, *rhs;
714 CHECK(Match(logical_and, m::And(m::Op(&lhs), m::Op(&rhs))));
715 // Simplify logical and
716 if (ShapeUtil::HasPrimitiveType(lhs->shape(), xla::PRED) &&
717 ShapeUtil::HasPrimitiveType(rhs->shape(), xla::PRED)) {
718 // A && True => A
719 VLOG(10) << "trying transform [A && True => A]: "
720 << logical_and->ToString();
721 if (IsAll(rhs, 1) && ReplaceInstructionIfSameShape(logical_and, lhs)) {
722 return Status::OK();
723 }
724 // True && A => A
725 VLOG(10) << "trying transform [True && A => A]: "
726 << logical_and->ToString();
727 if (IsAll(lhs, 1) && ReplaceInstructionIfSameShape(logical_and, rhs)) {
728 return Status::OK();
729 }
730 }
731
732 // A && False => False or A & 0 => 0
733 VLOG(10) << "trying transform [A && False => False]: "
734 << logical_and->ToString();
735 if (IsAll(rhs, 0) && ReplaceInstructionIfSameShape(logical_and, rhs)) {
736 return Status::OK();
737 }
738
739 // False && A => False or A & 0 => 0
740 VLOG(10) << "trying transform [False && A => False]: "
741 << logical_and->ToString();
742 if (IsAll(lhs, 0) && ReplaceInstructionIfSameShape(logical_and, lhs)) {
743 return Status::OK();
744 }
745
746 return Status::OK();
747}
748
749Status AlgebraicSimplifierVisitor::HandleBitcast(HloInstruction* bitcast) {
750 // If a bitcast feeds a bitcast, make it a single bitcast.

Callers 1

VisitMethod · 0.45

Calls 6

MatchFunction · 0.70
OpFunction · 0.70
IsAllFunction · 0.70
AndFunction · 0.50
shapeMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected