From e20f3f2a34204196b0046ad29707f346dd61a614 Mon Sep 17 00:00:00 2001 From: Alexander Redding Date: Thu, 19 Sep 2024 12:28:48 -0700 Subject: [PATCH] Fix (proxy): fix for float quant properties is_ocp and is_fnuz --- src/brevitas/proxy/float_parameter_quant.py | 4 ++-- src/brevitas/proxy/float_runtime_quant.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/brevitas/proxy/float_parameter_quant.py b/src/brevitas/proxy/float_parameter_quant.py index 4e6452792..7f86a5025 100644 --- a/src/brevitas/proxy/float_parameter_quant.py +++ b/src/brevitas/proxy/float_parameter_quant.py @@ -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') @@ -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 diff --git a/src/brevitas/proxy/float_runtime_quant.py b/src/brevitas/proxy/float_runtime_quant.py index b38f4ecdb..9b86ed515 100644 --- a/src/brevitas/proxy/float_runtime_quant.py +++ b/src/brevitas/proxy/float_runtime_quant.py @@ -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') @@ -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