109109#include " layer/yolodetectionoutput.h"
110110#include " layer/yolov3detectionoutput.h"
111111
112+ #if NCNN_WEIGHT_QUANT
112113static bool modelwriter_is_weight_block_quantize (int quantize_term)
113114{
114115 const int weight_bits = quantize_term / 100 ;
@@ -122,6 +123,7 @@ static bool modelwriter_weight_block_quantize_has_input_scale(int quantize_term)
122123{
123124 return quantize_term % 100 / 10 == 1 ;
124125}
126+ #endif // NCNN_WEIGHT_QUANT
125127
126128// for gen_random_weight
127129#include " ../tests/prng.h"
@@ -1895,8 +1897,11 @@ int ModelWriter::save(const char* parampath, const char* binpath)
18951897 fprintf_param_value (" 21=%d" , constant_TILE_N)
18961898 fprintf_param_value (" 22=%d" , constant_TILE_K)
18971899
1898- const bool weight_block_quantize
1899- = modelwriter_is_weight_block_quantize (op->quantize_term );
1900+ #if NCNN_WEIGHT_QUANT
1901+ const bool weight_block_quantize = modelwriter_is_weight_block_quantize (op->quantize_term );
1902+ #else
1903+ const bool weight_block_quantize = false ;
1904+ #endif
19001905
19011906 if (op->constantA == 1 )
19021907 {
@@ -1918,6 +1923,7 @@ int ModelWriter::save(const char* parampath, const char* binpath)
19181923 fwrite_weight_tag_data (op->C_data , bp);
19191924 }
19201925
1926+ #if NCNN_WEIGHT_QUANT
19211927 if (weight_block_quantize)
19221928 {
19231929 if (op->constantB == 1 )
@@ -1929,6 +1935,7 @@ int ModelWriter::save(const char* parampath, const char* binpath)
19291935 }
19301936 }
19311937 }
1938+ #endif // NCNN_WEIGHT_QUANT
19321939#if NCNN_INT8
19331940 // write int8_scale data
19341941 if (op->quantize_term && !weight_block_quantize)
@@ -2198,8 +2205,11 @@ int ModelWriter::save(const char* parampath, const char* binpath)
21982205 fprintf_param_value (" 7=%d" , kv_cache)
21992206 fprintf_param_value (" 18=%d" , quantize_term)
22002207
2201- const bool weight_block_quantize
2202- = modelwriter_is_weight_block_quantize (op->quantize_term );
2208+ #if NCNN_WEIGHT_QUANT
2209+ const bool weight_block_quantize = modelwriter_is_weight_block_quantize (op->quantize_term );
2210+ #else
2211+ const bool weight_block_quantize = false ;
2212+ #endif
22032213
22042214 if (weight_block_quantize)
22052215 {
@@ -2238,6 +2248,7 @@ int ModelWriter::save(const char* parampath, const char* binpath)
22382248 }
22392249 fwrite_weight_data (op->out_bias_data , bp);
22402250
2251+ #if NCNN_WEIGHT_QUANT
22412252 if (weight_block_quantize)
22422253 {
22432254 fwrite_weight_data (op->q_weight_data_quantize_scales , bp, false );
@@ -2252,9 +2263,10 @@ int ModelWriter::save(const char* parampath, const char* binpath)
22522263 fwrite_weight_data (op->out_weight_data_input_scales , bp, false );
22532264 }
22542265 }
2266+ #endif // NCNN_WEIGHT_QUANT
22552267#if NCNN_INT8
22562268 // write int8_scale data
2257- else if (op->quantize_term )
2269+ if (op->quantize_term && !weight_block_quantize )
22582270 {
22592271 fwrite_weight_data (op->q_weight_data_int8_scales , bp, 90 , 100 );
22602272 fwrite_weight_data (op->k_weight_data_int8_scales , bp, 90 , 100 );
0 commit comments