| 583 | } |
| 584 | |
| 585 | Status HloEvaluator::HandleReal(HloInstruction* real) { |
| 586 | auto operand = real->operand(0); |
| 587 | switch (operand->shape().element_type()) { |
| 588 | case BF16: { |
| 589 | auto result_or = ElementWiseUnaryOpImpl<bfloat16, bfloat16>( |
| 590 | real, [](bfloat16 elem_operand) { return elem_operand; }, |
| 591 | GetEvaluatedLiteralFor(operand)); |
| 592 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 593 | break; |
| 594 | } |
| 595 | case C64: { |
| 596 | auto result_or = ElementWiseUnaryOpImpl<float, complex64>( |
| 597 | real, [](complex64 elem_operand) { return std::real(elem_operand); }, |
| 598 | GetEvaluatedLiteralFor(operand)); |
| 599 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 600 | break; |
| 601 | } |
| 602 | case C128: { |
| 603 | auto result_or = ElementWiseUnaryOpImpl<double, complex128>( |
| 604 | real, [](complex128 elem_operand) { return std::real(elem_operand); }, |
| 605 | GetEvaluatedLiteralFor(operand)); |
| 606 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 607 | break; |
| 608 | } |
| 609 | case F16: { |
| 610 | auto result_or = ElementWiseUnaryOpImpl<Eigen::half, Eigen::half>( |
| 611 | real, [](Eigen::half elem_operand) { return elem_operand; }, |
| 612 | GetEvaluatedLiteralFor(operand)); |
| 613 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 614 | break; |
| 615 | } |
| 616 | case F32: { |
| 617 | auto result_or = ElementWiseUnaryOpImpl<float, float>( |
| 618 | real, [](float elem_operand) { return elem_operand; }, |
| 619 | GetEvaluatedLiteralFor(operand)); |
| 620 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 621 | break; |
| 622 | } |
| 623 | case F64: { |
| 624 | auto result_or = ElementWiseUnaryOpImpl<double, double>( |
| 625 | real, [](double elem_operand) { return elem_operand; }, |
| 626 | GetEvaluatedLiteralFor(operand)); |
| 627 | TF_ASSIGN_OR_RETURN(evaluated_[real], std::move(result_or)); |
| 628 | break; |
| 629 | } |
| 630 | default: |
| 631 | LOG(FATAL) << "HandleReal: unknown/unhandled primitive type: " |
| 632 | << PrimitiveType_Name(operand->shape().element_type()); |
| 633 | } |
| 634 | |
| 635 | return Status::OK(); |
| 636 | } |
| 637 | |
| 638 | Status HloEvaluator::HandleImag(HloInstruction* imag) { |
| 639 | auto operand = imag->operand(0); |
no test coverage detected