Skip to content

Commit

Permalink
Fix (proxy): fix for float quant properties is_ocp and is_fnuz (#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexredd99 authored Oct 8, 2024
1 parent 746d97e commit 0b18761
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/brevitas/proxy/float_parameter_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def is_ocp(self):
is_e4m3 = self.mantissa_bit_width() == 3 and self.exponent_bit_width() == 4
is_ocp_e4m3 = is_e4m3 and self.inf_values() is None and self.nan_values() == (('111',))

is_e5m2 = self.mantissa_bit_width() == 5 and self.exponent_bit_width() == 2
is_e5m2 = self.mantissa_bit_width() == 2 and self.exponent_bit_width() == 5
is_ocp_e5m2 = is_e5m2 and self.inf_values() == (
('00',)) and self.nan_values() == ('01', '11', '10')

Expand All @@ -79,7 +79,7 @@ def is_fnuz(self):
is_fnuz_e4m3 = is_e4m3 and self.inf_values() is None and self.nan_values(
) is None and self.exponent_bias() == 8

is_e5m2 = self.mantissa_bit_width() == 5 and self.exponent_bit_width() == 2
is_e5m2 = self.mantissa_bit_width() == 2 and self.exponent_bit_width() == 5
is_fnuz_e5m2 = is_e5m2 and self.inf_values() is None and self.nan_values(
) is None and self.exponent_bias() == 16
return is_fnuz_e4m3 or is_fnuz_e5m2
Expand Down
4 changes: 2 additions & 2 deletions src/brevitas/proxy/float_runtime_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def is_ocp(self):
is_e4m3 = self.mantissa_bit_width() == 3 and self.exponent_bit_width() == 4
is_ocp_e4m3 = is_e4m3 and self.inf_values() is None and self.nan_values() == (('111',))

is_e5m2 = self.mantissa_bit_width() == 5 and self.exponent_bit_width() == 2
is_e5m2 = self.mantissa_bit_width() == 2 and self.exponent_bit_width() == 5
is_ocp_e5m2 = is_e5m2 and self.inf_values() == (
('00',)) and self.nan_values() == ('01', '11', '10')

Expand All @@ -61,7 +61,7 @@ def is_fnuz(self):
is_fnuz_e4m3 = is_e4m3 and self.inf_values() is None and self.nan_values(
) is None and self.exponent_bias() == 8

is_e5m2 = self.mantissa_bit_width() == 5 and self.exponent_bit_width() == 2
is_e5m2 = self.mantissa_bit_width() == 2 and self.exponent_bit_width() == 5
is_fnuz_e5m2 = is_e5m2 and self.inf_values() is None and self.nan_values(
) is None and self.exponent_bias() == 16
return is_fnuz_e4m3 or is_fnuz_e5m2
Expand Down

0 comments on commit 0b18761

Please sign in to comment.