Imported from https://github.com/eladhoffer/quantized.pytorch