Fixed underflow error

This commit is contained in:
Andrew Kane
2024-03-30 15:04:33 -07:00
parent 968173690e
commit 56622e73fb
3 changed files with 6 additions and 2 deletions

View File

@@ -164,7 +164,7 @@ HalfToFloat4(half num)
/*
* Convert a float4 to a half
*/
static half
half
Float4ToHalfUnchecked(float num)
{
#ifdef FLT16_SUPPORT

View File

@@ -36,5 +36,6 @@ typedef struct HalfVector
HalfVector *InitHalfVector(int dim);
float HalfToFloat4(half num);
half Float4ToHalf(float num);
half Float4ToHalfUnchecked(float num);
#endif

View File

@@ -199,7 +199,10 @@ HnswNormValue(FmgrInfo *procinfo, Oid collation, Datum *value, int type)
HalfVector *result = InitHalfVector(v->dim);
for (int i = 0; i < v->dim; i++)
result->x[i] = Float4ToHalf(HalfToFloat4(v->x[i]) / norm);
{
/* TODO Fix */
result->x[i] = Float4ToHalfUnchecked(HalfToFloat4(v->x[i]) / norm);
}
*value = PointerGetDatum(result);
}