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

Method EmitCallToRuntime

tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc:604–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604Status DotOpEmitter::EmitCallToRuntime() {
605 // The signature of the Eigen runtime matmul function is:
606 //
607 // (void)(void* run_options, float* out, float* lhs, float* rhs,
608 // int64 m, int64 n, int64 k, int32 transpose_lhs,
609 // int32 transpose_rhs);
610 // The two transpose_... parameters are actually booleans, but we use int32
611 // to avoid target-dependent calling convention details.
612
613 bool multi_threaded = ShouldUseMultiThreadedEigen(hlo_module_config_);
614 bool use_mkl_dnn = hlo_module_config_.debug_options().xla_cpu_use_mkl_dnn();
615 PrimitiveType type = target_array_.GetShape().element_type();
616 llvm::Type* float_type;
617 const char* fn_name;
618 switch (type) {
619 case F16:
620 fn_name = multi_threaded
621 ? runtime::kEigenMatMulF16SymbolName
622 : runtime::kEigenSingleThreadedMatMulF16SymbolName;
623 float_type = b_->getHalfTy();
624 break;
625 case F32:
626 fn_name = multi_threaded
627 ? (use_mkl_dnn ? runtime::kMKLMatMulF32SymbolName
628 : runtime::kEigenMatMulF32SymbolName)
629 : (use_mkl_dnn
630 ? runtime::kMKLSingleThreadedMatMulF32SymbolName
631 : runtime::kEigenSingleThreadedMatMulF32SymbolName);
632 float_type = b_->getFloatTy();
633 break;
634 case F64:
635 fn_name = multi_threaded
636 ? (use_mkl_dnn ? runtime::kMKLMatMulF64SymbolName
637 : runtime::kEigenMatMulF64SymbolName)
638 : (use_mkl_dnn
639 ? runtime::kMKLSingleThreadedMatMulF64SymbolName
640 : runtime::kEigenSingleThreadedMatMulF64SymbolName);
641 float_type = b_->getDoubleTy();
642 break;
643 case S32:
644 fn_name = multi_threaded
645 ? runtime::kEigenMatMulS32SymbolName
646 : runtime::kEigenSingleThreadedMatMulS32SymbolName;
647 float_type = b_->getInt32Ty();
648 break;
649 default:
650 return Unimplemented("Invalid type %s for dot operation",
651 PrimitiveType_Name(type));
652 }
653
654 llvm::Type* float_ptr_type = float_type->getPointerTo();
655 llvm::Type* int64_type = b_->getInt64Ty();
656 llvm::Type* int32_type = b_->getInt32Ty();
657 llvm::Type* int8_ptr_type = b_->getInt8Ty()->getPointerTo();
658 llvm::FunctionType* matmul_type = llvm::FunctionType::get(
659 b_->getVoidTy(),
660 {int8_ptr_type, float_ptr_type, float_ptr_type, float_ptr_type,
661 int64_type, int64_type, int64_type, int32_type, int32_type},

Callers

nothing calls this directly

Calls 7

UnimplementedFunction · 0.85
getFunction · 0.50
element_typeMethod · 0.45
GetShapeMethod · 0.45
CreateCallMethod · 0.45
GetBasePointerMethod · 0.45

Tested by

no test coverage detected