MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / scalar_quantize_normal

Function scalar_quantize_normal

include/rabitqlib/utils/space.hpp:21–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19template <typename T>
20void scalar_quantize_normal(
21 T* __restrict__ result,
22 const float* __restrict__ vec0,
23 size_t dim,
24 float lo,
25 float delta
26) {
27 float one_over_delta = 1.0F / delta;
28
29 ConstRowMajorArrayMap<float> v0(vec0, 1, static_cast<long>(dim));
30 RowMajorArrayMap<T> res(result, 1, dim);
31
32 // round to nearest integer, then cast to integer
33 res = ((v0 - lo) * one_over_delta).round().template cast<T>();
34}
35
36template <typename T>
37void scalar_quantize_optimized(
38 T* __restrict__ result,

Calls

no outgoing calls

Tested by

no test coverage detected