vector-quantize-pytorch
vector-quantize-pytorch copied to clipboard
Bug in FSQ, with return_indices to False and image-type feature input
The new version of FSQ, with the possibility to not compute indices and return only None, has a small bug:
from vector_quantize_pytorch.finite_scalar_quantization import FSQ
import torch
quantizer = FSQ(levels=[8,5,5,5], return_indices=False)
images = torch.rand(1, 4, 32, 32)
quantizer(images)
the code above will raise a RuntimeError, as Einops try here to unpack None.
I will shortly propose a PR, which solves the issue and clean a bit the code, for better readability and ease of use.