@@ -581,12 +581,14 @@ def test_get_full_quantization_config(self):
581581 'symmetric' : False ,
582582 'granularity' : _QuantGranularity .TENSORWISE ,
583583 'dtype' : 'INT' ,
584+ 'max_hadamard_size' : 0 ,
584585 },
585586 'weight_tensor_config' : {
586587 'num_bits' : 8 ,
587588 'symmetric' : True ,
588589 'granularity' : _QuantGranularity .TENSORWISE ,
589590 'dtype' : 'INT' ,
591+ 'max_hadamard_size' : 0 ,
590592 },
591593 # WEIGHT_ONLY.
592594 'compute_precision' : _ComputePrecision .INTEGER ,
@@ -605,6 +607,7 @@ def test_get_full_quantization_config(self):
605607 'num_bits' : 8 ,
606608 'symmetric' : True ,
607609 'granularity' : _QuantGranularity .TENSORWISE ,
610+ 'max_hadamard_size' : 0 ,
608611 },
609612 # WEIGHT_ONLY.
610613 'compute_precision' : _ComputePrecision .FLOAT ,
@@ -623,6 +626,7 @@ def test_get_full_quantization_config(self):
623626 'num_bits' : 4 ,
624627 'symmetric' : True ,
625628 'granularity' : _QuantGranularity .TENSORWISE ,
629+ 'max_hadamard_size' : 0 ,
626630 },
627631 # WEIGHT_ONLY.
628632 'compute_precision' : _ComputePrecision .FLOAT ,
@@ -641,6 +645,7 @@ def test_get_full_quantization_config(self):
641645 'num_bits' : 6 ,
642646 'symmetric' : True ,
643647 'granularity' : _QuantGranularity .TENSORWISE ,
648+ 'max_hadamard_size' : 0 ,
644649 },
645650 # WEIGHT_ONLY.
646651 'compute_precision' : _ComputePrecision .FLOAT ,
@@ -659,6 +664,7 @@ def test_get_full_quantization_config(self):
659664 'num_bits' : 3 ,
660665 'symmetric' : True ,
661666 'granularity' : _QuantGranularity .TENSORWISE ,
667+ 'max_hadamard_size' : 0 ,
662668 },
663669 # WEIGHT_ONLY.
664670 'compute_precision' : _ComputePrecision .FLOAT ,
@@ -924,6 +930,26 @@ def test_need_calibration_true(self):
924930 )
925931 self .assertTrue (self ._recipe_manager .need_calibration ())
926932
933+ def test_get_hadamard_with_max_size (self ):
934+ self ._recipe_manager .add_quantization_config (
935+ regex = '.*/Dense/.*' ,
936+ operation_name = _TFLOpName .FULLY_CONNECTED ,
937+ algorithm_key = _AlgorithmName .HADAMARD_ROTATION ,
938+ op_config = qtyping .OpQuantizationConfig (
939+ weight_tensor_config = _TensorQuantConfig (
940+ num_bits = 8 , max_hadamard_size = 1024
941+ ),
942+ compute_precision = _ComputePrecision .INTEGER ,
943+ ),
944+ )
945+ alg_key , op_config = self ._recipe_manager .get_quantization_configs (
946+ _TFLOpName .FULLY_CONNECTED , 'model/Dense/op'
947+ )
948+ self .assertEqual (alg_key , _AlgorithmName .HADAMARD_ROTATION )
949+ weight_tensor_config = op_config .weight_tensor_config
950+ assert weight_tensor_config is not None
951+ self .assertEqual (weight_tensor_config .max_hadamard_size , 1024 )
952+
927953
928954if __name__ == '__main__' :
929955 googletest .main ()
0 commit comments