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

Method decode

src/ailego/algorithm/binary_quantizer.cc:61–73  ·  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

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