MCPcopy Create free account
hub / github.com/alibaba/zvec / decode

Method decode

src/ailego/algorithm/binary_quantizer.cc:62–74  ·  view source on GitHub ↗

De-quantize data: decode the input uint32_t to float output bit value 1 will be mapped to 1.0 bit value 0 will be mapped to -1.0

Source from the content-addressed store, hash-verified

60//! bit value 1 will be mapped to 1.0
61//! bit value 0 will be mapped to -1.0
62void BinaryQuantizer::decode(const uint32_t *in, size_t dim, float *out) const {
63 for (size_t i = 0; i < dim; ++i) {
64 uint8_t bit = (in[i >> 5] >> (i & 31)) & 0x01;
65
66 if (bit == 1) {
67 out[i] = 1.0f;
68 } else {
69 out[i] = -1.0f;
70 }
71
72 // std::cout << "dim: " << i << ", value: " << (size_t)bit << std::endl;
73 }
74}
75
76} // namespace ailego
77} // namespace zvec

Callers 5

embedMethod · 0.45
ParseFromJsonObjectFunction · 0.45
CreateMethod · 0.45
TESTFunction · 0.45
TESTFunction · 0.45

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36