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
| 60 | //! bit value 1 will be mapped to 1.0 |
| 61 | //! bit value 0 will be mapped to -1.0 |
| 62 | void 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 |