You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\short Gets size in bytes of encoded integer descriptor.
2856
+
\short Gets the size in bytes of an encoded integer descriptor produced by this engine.
2857
+
2858
+
The encoded descriptor consists of a 16-byte header (4 x 32-bit floats storing the inverse
2859
+
quantization scale, the minimum value, a precomputed sum helper, and the precomputed L2 norm)
2860
+
followed by the bit-packed quantized integer data. The total size equals
2861
+
16 + ceil(size * depth / 8), where \a size and \a depth are the values passed to ::SimdDescrIntInit.
2842
2862
2843
2863
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2844
-
\return size in bytes of encoded integer descriptor.
2864
+
\return the size in bytes of an encoded integer descriptor.
\short Gets length of original (32-bit or 16-bit) float descriptor.
2872
+
\short Gets the number of elements (floats) in the original descriptor.
2873
+
2874
+
This is the value of the \a size parameter that was passed to ::SimdDescrIntInit.
2875
+
It equals the number of 32-bit or 16-bit float elements in the uncompressed descriptor,
2876
+
and is the required length of the \a src buffer for ::SimdDescrIntEncode32f / ::SimdDescrIntEncode16f
2877
+
and the \a dst buffer for ::SimdDescrIntDecode32f / ::SimdDescrIntDecode16f.
2853
2878
2854
2879
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2855
-
\return length of original (32-bit or 16-bit) float descriptor.
2880
+
\return the number of float elements in the original (decoded) descriptor.
4. Packs the quantized values bit-by-bit (\a depth bits per element) into the output buffer
2896
+
starting at byte offset 16.
2897
+
5. Writes a 16-byte header at the beginning of \a dst containing four 32-bit floats:
2898
+
inverse scale (1/scale), minimum value (min), a precomputed sum helper used for
2899
+
dot-product reconstruction, and the precomputed L2 norm of the original descriptor.
2900
+
2901
+
The precomputed norm and sum helper in the header allow ::SimdDescrIntCosineDistance and
2902
+
related functions to compute cosine distances without decoding the descriptor.
2864
2903
2865
2904
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2866
-
\param [in] src - a pointer to original 32-bit float descriptor. Its length can be determined by function ::SimdDescrIntDecodedSize.
2867
-
\param [out] dst - a pointer to encoded integer descriptor. Its size in bytes can be determined by function ::SimdDescrIntEncodedSize.
2905
+
\param [in] src - a pointer to the input 32-bit float descriptor. The number of elements must equal the value returned by ::SimdDescrIntDecodedSize.
2906
+
\param [out] dst - a pointer to the output encoded integer descriptor. The buffer size in bytes must be at least the value returned by ::SimdDescrIntEncodedSize.
\short Encodes 16-bit float descriptor to integer form.
2914
+
\short Encodes a 16-bit float descriptor into a compact integer representation.
2915
+
2916
+
This function is identical in behavior to ::SimdDescrIntEncode32f except that the input
2917
+
descriptor elements are 16-bit floats (half precision, stored as uint16_t). Each element is
2918
+
first converted to 32-bit float internally, then quantized and packed in the same way.
2919
+
The output encoded descriptor format is identical to that produced by ::SimdDescrIntEncode32f
2920
+
and is fully compatible with all decode and distance functions.
2876
2921
2877
2922
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2878
-
\param [in] src - a pointer to original 16-bit float descriptor. Its length can be determined by function ::SimdDescrIntDecodedSize.
2879
-
\param [out] dst - a pointer to encoded integer descriptor. Its size in bytes can be determined by function ::SimdDescrIntEncodedSize.
2923
+
\param [in] src - a pointer to the input 16-bit float descriptor (half precision, stored as uint16_t). The number of elements must equal the value returned by ::SimdDescrIntDecodedSize.
2924
+
\param [out] dst - a pointer to the output encoded integer descriptor. The buffer size in bytes must be at least the value returned by ::SimdDescrIntEncodedSize.
\short Decodes integer descriptor to original 32-bit float form.
2932
+
\short Decodes an integer descriptor back into a 32-bit float descriptor.
2933
+
2934
+
The function reconstructs the original float values from the bit-packed quantized data
2935
+
using the inverse scale and minimum value stored in the 16-byte header of the encoded
2936
+
descriptor. Each reconstructed element is computed as: dst[i] = q[i] * invScale + min,
2937
+
where \a invScale and \a min are read from the first two 32-bit floats of \a src.
2938
+
The decoded values are approximations of the original floats; precision depends on \a depth.
2888
2939
2889
2940
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2890
-
\param [in] src - a pointer to encoded integer descriptor. Its size in bytes can be determined by function ::SimdDescrIntEncodedSize.
2891
-
\param [out] dst - a pointer to output 32-bit float descriptor. Its length can be determined by function ::SimdDescrIntDecodedSize.
2941
+
\param [in] src - a pointer to the encoded integer descriptor. The buffer size in bytes must be at least the value returned by ::SimdDescrIntEncodedSize.
2942
+
\param [out] dst - a pointer to the output 32-bit float descriptor. The number of elements must equal the value returned by ::SimdDescrIntDecodedSize.
\short Decodes integer descriptor to original 16-bit float form.
2950
+
\short Decodes an integer descriptor back into a 16-bit float descriptor.
2951
+
2952
+
This function is identical in behavior to ::SimdDescrIntDecode32f except that each
2953
+
reconstructed element is converted from 32-bit float to 16-bit float (half precision,
2954
+
stored as uint16_t) before being written to the output buffer.
2900
2955
2901
2956
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2902
-
\param [in] src - a pointer to encoded integer descriptor. Its size in bytes can be determined by function ::SimdDescrIntEncodedSize.
2903
-
\param [out] dst - a pointer to output 16-bit float descriptor. Its length can be determined by function ::SimdDescrIntDecodedSize.
2957
+
\param [in] src - a pointer to the encoded integer descriptor. The buffer size in bytes must be at least the value returned by ::SimdDescrIntEncodedSize.
2958
+
\param [out] dst - a pointer to the output 16-bit float descriptor (half precision, stored as uint16_t). The number of elements must equal the value returned by ::SimdDescrIntDecodedSize.
\short Calculates cosine distance of two integer descriptors.
2966
+
\short Calculates the cosine distance between two encoded integer descriptors.
2967
+
2968
+
The cosine distance is defined as: distance = 1 - dot(a, b) / (||a|| * ||b||),
2969
+
where \a a and \a b are treated as vectors in the original float space.
2970
+
The function computes the integer dot product directly on the bit-packed data and then
2971
+
reconstructs the true float dot product using the quantization scale and shift stored
2972
+
in the 16-byte headers of the encoded descriptors. The L2 norms are read directly from
2973
+
the precomputed values in the headers, avoiding full decoding.
2974
+
The result is clamped to the range [0, 2].
2912
2975
2913
-
\note Integer descriptor can be received with using of functions ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2976
+
\note An encoded integer descriptor is produced by ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2914
2977
2915
2978
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2916
-
\param [in] a - a pointer to the first integer descriptor.
2917
-
\param [in] b - a pointer to the second integer descriptor.
2918
-
\param [out] distance - a pointer to 32-bit float with cosine distance.
2979
+
\param [in] a - a pointer to the first encoded integer descriptor.
2980
+
\param [in] b - a pointer to the second encoded integer descriptor.
2981
+
\param [out] distance - a pointer to a 32-bit float that receives the cosine distance in the range [0, 2].
\fn void SimdDescrIntCosineDistancesMxNa(const void* context, size_t M, size_t N, const uint8_t* const* A, const uint8_t* const* B, float* distances);
2925
2988
2926
-
\short Calculates mutual cosine distance of two arrays of integer descriptor arrays.
2989
+
\short Calculates all pairwise cosine distances between two sets of encoded integer descriptors (array-of-pointers form).
2990
+
2991
+
Computes the M x N matrix of cosine distances, where distances[i * N + j] is the cosine
2992
+
distance between the i-th descriptor in \a A and the j-th descriptor in \a B.
2993
+
See ::SimdDescrIntCosineDistance for the definition of cosine distance.
2994
+
This variant accepts the descriptors through arrays of pointers, which allows non-contiguous
2995
+
memory layouts. For contiguous storage use ::SimdDescrIntCosineDistancesMxNp instead.
2996
+
The implementation automatically selects cache-friendly blocking strategies.
2927
2997
2928
-
\note Integer descriptor can be received with using of functions ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2998
+
\note An encoded integer descriptor is produced by ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2929
2999
2930
3000
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2931
-
\param [in] M - a number of A arrays.
2932
-
\param [in] N - a number of B arrays.
2933
-
\param [in] A - a pointer to the first array with pointers to integer descriptors.
2934
-
\param [in] B - a pointer to the second array with pointers to integer descriptors.
2935
-
\param [out] distances - a pointer to result 32-bit float array with cosine distances. It size must be M*N.
3001
+
\param [in] M - the number of descriptors in set \a A (number of rows in the output matrix).
3002
+
\param [in] N - the number of descriptors in set \a B (number of columns in the output matrix).
3003
+
\param [in] A - an array of M pointers, each pointing to an encoded integer descriptor.
3004
+
\param [in] B - an array of N pointers, each pointing to an encoded integer descriptor.
3005
+
\param [out] distances - a pointer to the output M x N matrix of 32-bit float cosine distances stored in row-major order. The buffer must hold at least M * N elements.
2936
3006
*/
2937
3007
SIMD_API void SimdDescrIntCosineDistancesMxNa(const void* context, size_t M, size_t N, const uint8_t* const* A, const uint8_t* const* B, float* distances);
2938
3008
2939
3009
/*! @ingroup descrint
2940
3010
2941
3011
\fn void SimdDescrIntCosineDistancesMxNp(const void* context, size_t M, size_t N, const uint8_t* A, const uint8_t* B, float* distances);
2942
3012
2943
-
\short Calculates mutual cosine distance of two arrays of integer descriptors.
3013
+
\short Calculates all pairwise cosine distances between two sets of encoded integer descriptors (packed/contiguous form).
2944
3014
2945
-
\note Integer descriptor can be received with using of functions ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
3015
+
Computes the M x N matrix of cosine distances, where distances[i * N + j] is the cosine
3016
+
distance between the i-th descriptor in \a A and the j-th descriptor in \a B.
3017
+
See ::SimdDescrIntCosineDistance for the definition of cosine distance.
3018
+
This variant accepts the descriptors as two flat contiguous arrays, where descriptor \a i
3019
+
starts at A + i * encodedSize and descriptor \a j starts at B + j * encodedSize,
3020
+
with encodedSize returned by ::SimdDescrIntEncodedSize.
3021
+
For non-contiguous memory layouts use ::SimdDescrIntCosineDistancesMxNa instead.
3022
+
3023
+
\note An encoded integer descriptor is produced by ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2946
3024
2947
3025
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2948
-
\param [in] M - a number of A arrays.
2949
-
\param [in] N - a number of B arrays.
2950
-
\param [in] A - a pointer to the first array with integer descriptors.
2951
-
\param [in] B - a pointer to the second array with integer descriptors.
2952
-
\param [out] distances - a pointer to result 32-bit float array with cosine distances. It size must be M*N.
3026
+
\param [in] M - the number of descriptors in set \a A (number of rows in the output matrix).
3027
+
\param [in] N - the number of descriptors in set \a B (number of columns in the output matrix).
3028
+
\param [in] A - a pointer to the contiguous array of M encoded integer descriptors.
3029
+
\param [in] B - a pointer to the contiguous array of N encoded integer descriptors.
3030
+
\param [out] distances - a pointer to the output M x N matrix of 32-bit float cosine distances stored in row-major order. The buffer must hold at least M * N elements.
2953
3031
*/
2954
3032
SIMD_API void SimdDescrIntCosineDistancesMxNp(const void* context, size_t M, size_t N, const uint8_t* A, const uint8_t* B, float* distances);
2955
3033
2956
3034
/*! @ingroup descrint
2957
3035
2958
3036
\fn void SimdDescrIntVectorNorm(const void* context, const uint8_t* a, float* norm);
2959
3037
2960
-
\short Calculates vector norm for integer descriptor.
3038
+
\short Gets the precomputed L2 norm of an encoded integer descriptor.
3039
+
3040
+
The L2 norm of the original float descriptor is computed and stored in the 16-byte header
3041
+
of the encoded descriptor during encoding (by ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f).
3042
+
This function retrieves that precomputed value without performing any additional computation.
3043
+
The norm equals the Euclidean length of the original float descriptor before quantization.
2961
3044
2962
-
\note Integer descriptor can be received with using of functions ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
3045
+
\note An encoded integer descriptor is produced by ::SimdDescrIntEncode32f or ::SimdDescrIntEncode16f. Its size in bytes is determined by function ::SimdDescrIntEncodedSize.
2963
3046
2964
3047
\param [in] context - a pointer to Integer Descriptor Engine context. It must be created by function ::SimdDescrIntInit and released by function ::SimdRelease.
2965
-
\param [in] a - a pointer to integer descriptor.
2966
-
\param [out] norm - a pointer to result 32-bit float norm.
3048
+
\param [in] a - a pointer to the encoded integer descriptor.
3049
+
\param [out] norm - a pointer to a 32-bit float that receives the precomputed L2 norm of the original float descriptor.
2967
3050
*/
2968
3051
SIMD_API void SimdDescrIntVectorNorm(const void* context, const uint8_t* a, float* norm);
0 commit comments