| 2578 | } |
| 2579 | |
| 2580 | Status AlgebraicSimplifierVisitor::HandleCompare(HloInstruction* compare) { |
| 2581 | HloInstruction* lhs; |
| 2582 | HloInstruction* rhs; |
| 2583 | CHECK(Match(compare, m::Compare(m::Op(&lhs), m::Op(&rhs)))); |
| 2584 | |
| 2585 | if (compare->comparison_direction() == ComparisonDirection::kLt && |
| 2586 | lhs->opcode() == HloOpcode::kIota && IsAll(rhs, 0)) { |
| 2587 | return ReplaceInstruction(compare, MakeScalarLike(compare, false)); |
| 2588 | } else if (compare->comparison_direction() == ComparisonDirection::kGt && |
| 2589 | IsAll(lhs, 0) && rhs->opcode() == HloOpcode::kIota) { |
| 2590 | return ReplaceInstruction(compare, MakeScalarLike(compare, false)); |
| 2591 | } else if (compare->comparison_direction() == ComparisonDirection::kGe && |
| 2592 | lhs->opcode() == HloOpcode::kIota && IsAll(rhs, 0)) { |
| 2593 | return ReplaceInstruction(compare, MakeScalarLike(compare, true)); |
| 2594 | } else if (compare->comparison_direction() == ComparisonDirection::kLe && |
| 2595 | IsAll(lhs, 0) && rhs->opcode() == HloOpcode::kIota) { |
| 2596 | return ReplaceInstruction(compare, MakeScalarLike(compare, true)); |
| 2597 | } |
| 2598 | if (lhs == rhs && |
| 2599 | primitive_util::IsIntegralType(lhs->shape().element_type())) { |
| 2600 | switch (compare->comparison_direction()) { |
| 2601 | case ComparisonDirection::kGt: |
| 2602 | case ComparisonDirection::kLt: |
| 2603 | case ComparisonDirection::kNe: |
| 2604 | return ReplaceInstruction(compare, MakeScalarLike(compare, false)); |
| 2605 | case ComparisonDirection::kEq: |
| 2606 | case ComparisonDirection::kGe: |
| 2607 | case ComparisonDirection::kLe: |
| 2608 | return ReplaceInstruction(compare, MakeScalarLike(compare, true)); |
| 2609 | } |
| 2610 | } |
| 2611 | return Status::OK(); |
| 2612 | } |
| 2613 | |
| 2614 | Status AlgebraicSimplifierVisitor::HandleConvert(HloInstruction* convert) { |
| 2615 | PrimitiveType src_type = convert->operand(0)->shape().element_type(); |
nothing calls this directly
no test coverage detected