| 1034 | } |
| 1035 | |
| 1036 | std::shared_ptr<CastFunction> GetCastToHalfFloat() { |
| 1037 | // HalfFloat is a bit brain-damaged for now |
| 1038 | auto func = std::make_shared<CastFunction>("func", Type::HALF_FLOAT); |
| 1039 | AddCommonCasts(Type::HALF_FLOAT, float16(), func.get()); |
| 1040 | |
| 1041 | // Casts from integer to floating point |
| 1042 | for (const std::shared_ptr<DataType>& in_ty : IntTypes()) { |
| 1043 | DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, |
| 1044 | TypeTraits<HalfFloatType>::type_singleton(), |
| 1045 | CastIntegerToFloating)); |
| 1046 | } |
| 1047 | |
| 1048 | // Cast from other strings to half float. |
| 1049 | for (const std::shared_ptr<DataType>& in_ty : BaseBinaryTypes()) { |
| 1050 | auto exec = GenerateVarBinaryBase<CastFunctor, HalfFloatType>(*in_ty); |
| 1051 | DCHECK_OK(func->AddKernel(in_ty->id(), {in_ty}, |
| 1052 | TypeTraits<HalfFloatType>::type_singleton(), exec)); |
| 1053 | } |
| 1054 | |
| 1055 | DCHECK_OK(func.get()->AddKernel(Type::FLOAT, {InputType(Type::FLOAT)}, float16(), |
| 1056 | CastFloatingToFloating)); |
| 1057 | DCHECK_OK(func.get()->AddKernel(Type::DOUBLE, {InputType(Type::DOUBLE)}, float16(), |
| 1058 | CastFloatingToFloating)); |
| 1059 | return func; |
| 1060 | } |
| 1061 | |
| 1062 | struct NullExtensionTypeMatcher : public TypeMatcher { |
| 1063 | ~NullExtensionTypeMatcher() override = default; |
no test coverage detected