@@ -77,8 +77,19 @@ def parse_args():
7777
7878 parser .add_argument ('-wi' , '--conv_algo' , dest = 'conv_algo' , action = "store_true" , default = False ,
7979 help = 'to choose the convolution algorithm' )
80+
8081 parser .add_argument ('-1st' , '--enable_1st_conv_layer' , dest = 'enable_1st_conv_layer' , action = "store_true" , default = False ,
8182 help = 'enable 1st conv layer' )
83+
84+ parser .add_argument ('-fc' , '--fc_int8' , dest = 'fc_int8' , action = "store_true" , default = False ,
85+ help = 'enable int8 fc layer' )
86+
87+ parser .add_argument ('-uff' , '--disable_force_fp32' , dest = 'disable_force_fp32' , action = "store_true" , default = False ,
88+ help = 'to disable force fp32 output in conv/fc + fp32' )
89+
90+ parser .add_argument ('-ucac' , '--disable_cac_unify' , dest = 'disable_cac_unify' , action = "store_true" , default = False ,
91+ help = 'to disable scale unify in conv/fc + avg pooling + conv/fc' )
92+
8293 if len (sys .argv ) == 1 :
8394 parser .print_help ()
8495 sys .exit (1 )
@@ -119,6 +130,8 @@ def parse_args():
119130 if args .quantized_prototxt == None :
120131 test_net (net , imdb , max_per_image = args .max_per_image , vis = args .vis )
121132 else :
133+ if args .fc_int8 :
134+ calibrator .enable_fc_int8 ()
122135 (blobs , params , top_blobs_map , bottom_blobs_map , conv_top_blob_layer_map , conv_bottom_blob_layer_map , winograd_bottoms , winograd_convolutions ) = sample_net (args .prototxt , net , imdb , args .sample_iters , args .quant_mode , args .enable_1st_conv_layer )
123136
124137 (inputs_max , outputs_max , inputs_min ) = sampling .calibrate_activations (blobs , conv_top_blob_layer_map , conv_bottom_blob_layer_map , winograd_bottoms , args .calibration_algos , "SINGLE" , args .conv_algo )
@@ -130,3 +143,7 @@ def parse_args():
130143 with open (compile_net_path , "w" ) as f :
131144 f .write (compiled_net_str )
132145 calibrator .transform_convolutions (args .quantized_prototxt , compile_net_path , top_blobs_map , bottom_blobs_map , args .unsigned_range , args .concat_use_fp32 , args .unify_concat_scales , args .conv_algo , args .enable_1st_conv_layer )
146+ if not args .disable_force_fp32 :
147+ calibrator .force_fp32_opt (args .quantized_prototxt )
148+ if not args .disable_cac_unify :
149+ calibrator .cac_opt (args .quantized_prototxt )
0 commit comments