Skip to content

Commit

Permalink
Fix (proxy): fix for float quant properties is_ocp and is_fnuz
Browse files Browse the repository at this point in the history
  • Loading branch information
alexredd99 committed Sep 19, 2024
1 parent 3a9bcc6 commit e20f3f2
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 @@ -66,7 +66,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 @@ -78,7 +78,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 @@ -41,7 +41,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 @@ -53,7 +53,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 e20f3f2

Please sign in to comment.