Skip to content

Commit

Permalink
address #101
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jan 15, 2024
1 parent 13dd330 commit e84e394
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'vector_quantize_pytorch',
packages = find_packages(),
version = '1.12.10',
version = '1.12.11',
license='MIT',
description = 'Vector Quantization - Pytorch',
long_description_content_type = 'text/markdown',
Expand Down
8 changes: 6 additions & 2 deletions vector_quantize_pytorch/vector_quantize_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ def forward(
ema_inplace(self.cluster_size.data, cluster_size, self.decay)

embed_sum = einsum('h n d, h n c -> h c d', flatten, embed_onehot)
self.all_reduce_fn(embed_sum.contiguous())
embed_sum = embed_sum.contiguous()
self.all_reduce_fn(embed_sum)

ema_inplace(self.embed_avg.data, embed_sum, self.decay)

cluster_size = laplace_smoothing(self.cluster_size, self.codebook_size, self.eps) * self.cluster_size.sum(dim = -1, keepdim = True)
Expand Down Expand Up @@ -664,7 +666,9 @@ def forward(
ema_inplace(self.cluster_size.data, bins, self.decay)

embed_sum = einsum('h n d, h n c -> h c d', flatten, embed_onehot)
self.all_reduce_fn(embed_sum.contiguous())
embed_sum = embed_sum.contiguous()
self.all_reduce_fn(embed_sum)

ema_inplace(self.embed_avg.data, embed_sum, self.decay)

cluster_size = laplace_smoothing(self.cluster_size, self.codebook_size, self.eps) * self.cluster_size.sum(dim = -1, keepdim = True)
Expand Down

0 comments on commit e84e394

Please sign in to comment.