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

Method HandleReal

tensorflow/compiler/xla/service/hlo_evaluator.cc:585–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585Status 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
638Status HloEvaluator::HandleImag(HloInstruction* imag) {
639 auto operand = imag->operand(0);

Callers 1

VisitMethod · 0.45

Calls 5

realFunction · 0.85
TF_ASSIGN_OR_RETURNFunction · 0.70
operandMethod · 0.45
element_typeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected