Skip to content

Commit

Permalink
fix: fix dtype check in quantizer dequant
Browse files Browse the repository at this point in the history
The commit fixes a dtype check that we have in the `dequant` method of
our quantizer.

Dtype objects are weird.
https://stackoverflow.com/questions/26921836/correct-way-to-test-for-numpy-dtype
  • Loading branch information
fd0r committed Jul 25, 2024
1 parent 1988936 commit 77ced60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/concrete/ml/quantization/quantizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ class QuantizationOptions:
is_precomputed_qat: bool = False

def __init__(
self, n_bits: int, is_signed: bool = False, is_symmetric: bool = False, is_qat: bool = False
self,
n_bits: int,
is_signed: bool = False,
is_symmetric: bool = False,
is_qat: bool = False,
):
self.n_bits = n_bits
self.is_signed = is_signed
Expand Down Expand Up @@ -789,7 +793,7 @@ def dequant(self, qvalues: numpy.ndarray) -> Union[float, numpy.ndarray, Tracer]

assert_true(
isinstance(self.scale, (numpy.floating, float))
or (isinstance(self.scale, numpy.ndarray) and self.scale.dtype is numpy.float64),
or (isinstance(self.scale, numpy.ndarray) and self.scale.dtype == numpy.float64),
"Scale is a of type "
+ type(self.scale).__name__
+ ((" " + str(self.scale.dtype)) if isinstance(self.scale, numpy.ndarray) else ""),
Expand Down

0 comments on commit 77ced60

Please sign in to comment.