Functions for conversion between 16-bit and 32-bit float numbers and other. More...
Functions | |
SIMD_API void | SimdFloat32ToFloat16 (const float *src, size_t size, uint16_t *dst) |
Converts numbers in the array from 32-bit float to 16-bit float format. More... | |
SIMD_API void | SimdFloat16ToFloat32 (const uint16_t *src, size_t size, float *dst) |
Converts numbers in the array from 16-bit float to 32-bit float format. More... | |
SIMD_API void | SimdSquaredDifferenceSum16f (const uint16_t *a, const uint16_t *b, size_t size, float *sum) |
Calculates sum of squared differences for two 16-bit float arrays. More... | |
SIMD_API void | SimdCosineDistance16f (const uint16_t *a, const uint16_t *b, size_t size, float *distance) |
Calculates cosine distance of two 16-bit float arrays. More... | |
SIMD_API void | SimdCosineDistancesMxNa16f (size_t M, size_t N, size_t K, const uint16_t *const *A, const uint16_t *const *B, float *distances) |
Calculates mutual cosine distance of two arrays of 16-bit float arrays. More... | |
SIMD_API void | SimdCosineDistancesMxNp16f (size_t M, size_t N, size_t K, const uint16_t *A, const uint16_t *B, float *distances) |
Calculates mutual cosine distance of two arrays of 16-bit float arrays. More... | |
SIMD_API void | SimdVectorNormNa16f (size_t N, size_t K, const uint16_t *const *A, float *norms) |
Calculates vector norms for array of 16-bit float arrays. More... | |
SIMD_API void | SimdVectorNormNp16f (size_t N, size_t K, const uint16_t *A, float *norms) |
Calculates vector norms for array of 16-bit float arrays. More... | |
Detailed Description
Functions for conversion between 16-bit and 32-bit float numbers and other.
Function Documentation
◆ SimdFloat32ToFloat16()
void SimdFloat32ToFloat16 | ( | const float * | src, |
size_t | size, | ||
uint16_t * | dst | ||
) |
Converts numbers in the array from 32-bit float to 16-bit float format.
- Parameters
-
[in] src - a pointer to the input array with 32-bit float point numbers. [in] size - a size of input and output array. [out] dst - a pointer to the output array with 16-bit float point numbers.
◆ SimdFloat16ToFloat32()
void SimdFloat16ToFloat32 | ( | const uint16_t * | src, |
size_t | size, | ||
float * | dst | ||
) |
Converts numbers in the array from 16-bit float to 32-bit float format.
- Parameters
-
[in] src - a pointer to the input array with 16-bit float point numbers. [in] size - a size of input and output array. [out] dst - a pointer to the output array with 32-bit float point numbers.
◆ SimdSquaredDifferenceSum16f()
void SimdSquaredDifferenceSum16f | ( | const uint16_t * | a, |
const uint16_t * | b, | ||
size_t | size, | ||
float * | sum | ||
) |
Calculates sum of squared differences for two 16-bit float arrays.
All arrays must have the same size.
For every element:
sum += (a[i] - b[i])*(a[i] - b[i]);
- Parameters
-
[in] a - a pointer to the first 16-bit float array. [in] b - a pointer to the second 16-bit float array. [in] size - a size of arrays. [out] sum - a pointer to 32-bit float point sum of squared differences.
◆ SimdCosineDistance16f()
void SimdCosineDistance16f | ( | const uint16_t * | a, |
const uint16_t * | b, | ||
size_t | size, | ||
float * | distance | ||
) |
Calculates cosine distance of two 16-bit float arrays.
All arrays must have the same size.
Algorithm description:
distance = 1 - Sum(a[i]*b[i])/Sqrt(Sum(a[i]*a[i])*Sum(b[i]*b[i]));
- Parameters
-
[in] a - a pointer to the first 16-bit float array. [in] b - a pointer to the second 16-bit float array. [in] size - a size of arrays. [out] distance - a pointer to 32-bit float with cosine distance.
◆ SimdCosineDistancesMxNa16f()
void SimdCosineDistancesMxNa16f | ( | size_t | M, |
size_t | N, | ||
size_t | K, | ||
const uint16_t *const * | A, | ||
const uint16_t *const * | B, | ||
float * | distances | ||
) |
Calculates mutual cosine distance of two arrays of 16-bit float arrays.
Algorithm description:
distances[i, j] = 1 - Sum(A[i][k]*B[j][k])/Sqrt(Sum(A[i][k]*A[i][k])*Sum(B[j][k]*B[j][k]));
- Parameters
-
[in] M - a number of A arrays. [in] N - a number of B arrays. [in] K - a size of A and B arrays. [in] A - a pointer to the first array with pointers to 16-bit float arrays. [in] B - a pointer to the second array with pointers to 16-bit float arrays. [out] distances - a pointer to result 32-bit float array with cosine distances. It size must be M*N.
◆ SimdCosineDistancesMxNp16f()
void SimdCosineDistancesMxNp16f | ( | size_t | M, |
size_t | N, | ||
size_t | K, | ||
const uint16_t * | A, | ||
const uint16_t * | B, | ||
float * | distances | ||
) |
Calculates mutual cosine distance of two arrays of 16-bit float arrays.
Algorithm description:
distances[i, j] = 1 - Sum(A[i*K + k]*B[j*K + k])/Sqrt(Sum(A[i*K + k]*A[i*K + k])*Sum(B[j*K + k]*B[j*K + k]));
- Parameters
-
[in] M - a number of A arrays. [in] N - a number of B arrays. [in] K - a size of A and B arrays. [in] A - a pointer to 16-bit float arrays. [in] B - a pointer to 16-bit float arrays. [out] distances - a pointer to result 32-bit float array with cosine distances. It size must be M*N.
◆ SimdVectorNormNa16f()
void SimdVectorNormNa16f | ( | size_t | N, |
size_t | K, | ||
const uint16_t *const * | A, | ||
float * | norms | ||
) |
Calculates vector norms for array of 16-bit float arrays.
Algorithm description:
norms[j] = Sqrt(Sum(A[j][k]*A[j][k]));
- Parameters
-
[in] N - a number of A arrays. [in] K - a size of A arrays. [in] A - a pointer to the array with pointers to 16-bit float arrays. [out] norms - a pointer to result 32-bit float array with vector norms. It size must be N.
◆ SimdVectorNormNp16f()
void SimdVectorNormNp16f | ( | size_t | N, |
size_t | K, | ||
const uint16_t * | A, | ||
float * | norms | ||
) |
Calculates vector norms for array of 16-bit float arrays.
Algorithm description:
norms[j] = Sqrt(Sum(A[j*K + k]*A[j*K + k]));
- Parameters
-
[in] N - a number of A arrays. [in] K - a size of A arrays. [in] A - a pointer to 16-bit float arrays. [out] norms - a pointer to result 32-bit float array with vector norms. It size must be N.