MCPcopy Index your code
hub / github.com/ml-explore/mlx-examples / quantize

Method quantize

encodec/encodec.py:377–386  ·  view source on GitHub ↗
(self, hidden_states)

Source from the content-addressed store, hash-verified

375 self.embed = mx.zeros((config.codebook_size, config.codebook_dim))
376
377 def quantize(self, hidden_states):
378 embed = self.embed.T
379 scaled_states = hidden_states.square().sum(axis=1, keepdims=True)
380 dist = -(
381 scaled_states
382 - 2 * hidden_states @ embed
383 + embed.square().sum(axis=0, keepdims=True)
384 )
385 embed_ind = dist.argmax(axis=-1)
386 return embed_ind
387
388 def encode(self, hidden_states):
389 shape = hidden_states.shape

Callers 15

encodeMethod · 0.95
txt2image.pyFile · 0.45
loadFunction · 0.45
quantizeFunction · 0.45
load_modelFunction · 0.45
quantizeFunction · 0.45
loadFunction · 0.45
load_modelFunction · 0.45
quantizeFunction · 0.45
load_modelFunction · 0.45
quantizeFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected