mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-05 12:10:55 +08:00
Fixed underflow error
This commit is contained in:
@@ -164,7 +164,7 @@ HalfToFloat4(half num)
|
|||||||
/*
|
/*
|
||||||
* Convert a float4 to a half
|
* Convert a float4 to a half
|
||||||
*/
|
*/
|
||||||
static half
|
half
|
||||||
Float4ToHalfUnchecked(float num)
|
Float4ToHalfUnchecked(float num)
|
||||||
{
|
{
|
||||||
#ifdef FLT16_SUPPORT
|
#ifdef FLT16_SUPPORT
|
||||||
|
|||||||
@@ -36,5 +36,6 @@ typedef struct HalfVector
|
|||||||
HalfVector *InitHalfVector(int dim);
|
HalfVector *InitHalfVector(int dim);
|
||||||
float HalfToFloat4(half num);
|
float HalfToFloat4(half num);
|
||||||
half Float4ToHalf(float num);
|
half Float4ToHalf(float num);
|
||||||
|
half Float4ToHalfUnchecked(float num);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -199,7 +199,10 @@ HnswNormValue(FmgrInfo *procinfo, Oid collation, Datum *value, int type)
|
|||||||
HalfVector *result = InitHalfVector(v->dim);
|
HalfVector *result = InitHalfVector(v->dim);
|
||||||
|
|
||||||
for (int i = 0; i < v->dim; i++)
|
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);
|
*value = PointerGetDatum(result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user