Skip to content

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-stoian-zama committed Oct 17, 2024
1 parent 96b22eb commit c91ee33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/concrete/ml/quantization/base_quantized_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,18 @@ def calibrate(self, *inputs: Union[QuantizedArray, numpy.ndarray]) -> numpy.ndar
if isinstance(raw_result, RawOpOutput):
return raw_result

supports_analytical_quant = all(
# If the caller passes only QuantizedArray it means
# that they are asking to quantized using analytical
# formulas
requested_analytical_quant = all(
isinstance(qv, QuantizedArray) for qv in inputs
) and isinstance(self, QuantizedMixingOp)
if supports_analytical_quant:
if requested_analytical_quant:
assert_true(
self.supported_by_linear_backend(),
"Calibration using QuantizedArray is only possible"
" for operations that can calibrate analytically",
)
q_prepared_inputs = self._prepare_inputs_with_constants(
*inputs, calibrate=False, quantize_actual_values=True
)
Expand Down
4 changes: 2 additions & 2 deletions src/concrete/ml/quantization/quantized_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ def q_impl(
# Using snake case here to please the Python format, the original attrs don't have the '_'
# Use default false so we also support MatMul impl, MatMul does not have these flags
transpose_inputs1 = attrs.get("transA", False)
transpose_inputs2 = attrs.get("transB", False)

with tag(self.op_instance_name + ".input"):
input1_q_values = (
numpy.transpose(q_input1.qvalues) if transpose_inputs1 else q_input1.qvalues
)

transpose_inputs2 = attrs.get("transB", False)
input2_q_values = (
numpy.transpose(q_input2.qvalues) if transpose_inputs2 else q_input2.qvalues
)
Expand Down

0 comments on commit c91ee33

Please sign in to comment.