MCPcopy Create free account
hub / github.com/apache/arrow / GetCastToHalfFloat

Function GetCastToHalfFloat

cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc:1036–1060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036std::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
1062struct NullExtensionTypeMatcher : public TypeMatcher {
1063 ~NullExtensionTypeMatcher() override = default;

Callers 1

GetNumericCastsFunction · 0.85

Calls 6

AddCommonCastsFunction · 0.85
InputTypeFunction · 0.85
type_singletonFunction · 0.70
getMethod · 0.45
AddKernelMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected