MCPcopy Create free account
hub / github.com/dblalock/bolt / dists_sq

Method dists_sq

python/bolt/bolt_api.py:333–371  ·  view source on GitHub ↗
(self, q)

Source from the content-addressed store, hash-verified

331 # dists = np.sum(centroid_dists.reshape(self.X_enc.shape), axis=-1)
332
333 def dists_sq(self, q):
334 lut = _fit_pq_lut(q, centroids=self.centroids,
335 elemwise_dist_func=dists_elemwise_sq)
336
337 offsets_cpp = self._encoder.get_offsets()
338 scale_cpp = self._encoder.get_scale()
339
340 # print "py, cpp offsets:"
341 # print self.offsets
342 # print offsets_cpp
343
344 # print "py, cpp scale factors:"
345 # print self.scale
346 # print scale_cpp
347
348 lut_py = self._quantize_lut(lut)
349 # print "lets try to read the cpp lut..."
350 # self._encoder.lut_l2(q)
351 self._encoder.lut_dot(q)
352 lut_cpp = self._encoder.get_lut()
353
354 print "py, cpp lut:" # within +/- 1 using naive lut impl in cpp
355 print lut_py
356 print lut_cpp
357
358 # return self._dists(lut)
359 dists_py = self._dists(lut)
360 dists_cpp = self._encoder.dists_sq(q)[:len(dists_py)] # strip padding
361
362 # print "py, cpp initial dists:"
363 # print dists_py[:20]
364 # print dists_cpp[:20]
365
366 # print "py, cpp final dists:"
367 # print dists_py[-20:]
368 # print dists_cpp[-20:]
369
370 return dists_py
371 # return dists_cpp
372
373 def dot_prods(self, q):
374 lut = _fit_pq_lut(q, centroids=self.centroids,

Callers

nothing calls this directly

Calls 7

_quantize_lutMethod · 0.95
_distsMethod · 0.95
get_offsetsMethod · 0.80
get_scaleMethod · 0.80
lut_dotMethod · 0.80
get_lutMethod · 0.80
_fit_pq_lutFunction · 0.70

Tested by

no test coverage detected