MCPcopy Create free account
hub / github.com/Xilinx/CHaiDNN / ExtractPrecisionParameters

Function ExtractPrecisionParameters

software/xtract/caffe_network_parser.cpp:3228–3311  ·  view source on GitHub ↗

Extract FP Precision Parameters

Source from the content-addressed store, hash-verified

3226
3227// Extract FP Precision Parameters
3228bool ExtractPrecisionParameters(const caffe::LayerParameter& src, XLayer& layer, bool isParamsPrecisionMandatory) {
3229 bool parsedSuccessfully = true;
3230
3231 // Check if it is a single precision layer
3232 if(SWLayerSet.find(layer.type) != SWLayerSet.end()) {
3233 layer.quantization_scheme = "SinglePrecision";
3234 return true;
3235 }
3236
3237 // precision_param() or quantization_param() ?
3238 string field_type = "";
3239
3240 if(src.has_precision_param()) {
3241 // src_params = &(src.precision_param());
3242 layer.quantization_scheme = src.precision_param().quant_type();
3243 field_type = "precision";
3244 }
3245 else if(src.has_quantization_param()) {
3246 // src_params = &(src.quantization_param());
3247 layer.quantization_scheme = src.quantization_param().quant_type();
3248 field_type = "quantization";
3249 }
3250 else {
3251 parsedSuccessfully = false;
3252 }
3253
3254 layer.quantization_scheme = layer.quantization_scheme.empty() ? "DynamicFixed" : layer.quantization_scheme;
3255
3256 // quant_type should be either "DynamicFixed" or "Xilinx" (if empty, by default it is Dynamic Fixed)
3257 ASSERT((layer.quantization_scheme == "DynamicFixed" || layer.quantization_scheme == "Xilinx"), EP501,
3258 "Quantization Scheme should be either \"DynamicFixed\" or \"Xilinx\". "
3259 "Quantization Scheme of layer " << layer.name << " is " << "\"" << layer.quantization_scheme << "\""
3260 << " which is not supported" )
3261
3262 // INFO : Special case : Don't run precision extraction for Maxpool DynamicFixed format
3263 // TODO : Maxpool has prec param only in Offline mode, not in DynamicFixed mode. Better keep same pattern everywhere.
3264 if(layer.quantization_scheme == "DynamicFixed") {
3265 if ((layer.type == "Pooling" && layer.pool_params->PoolType == MAX) ||
3266 (layer.type == "Concat") || (layer.type == "Softmax"))
3267 {
3268 return true;
3269 }
3270 }
3271
3272 // Parse based on the quantization_scheme
3273 if(layer.quantization_scheme == "DynamicFixed") {
3274 if(field_type == "precision") {
3275 parsedSuccessfully = ExtractDynamicFixedPointParameters(src.precision_param(), layer, isParamsPrecisionMandatory, parsedSuccessfully);
3276 }
3277 else { // quantization
3278 parsedSuccessfully = ExtractDynamicFixedPointParameters(src.quantization_param(), layer, isParamsPrecisionMandatory, parsedSuccessfully);
3279 }
3280 }
3281 else if(layer.quantization_scheme == "Xilinx") {
3282 if(field_type == "precision") {
3283 parsedSuccessfully = ExtractOfflineQuantizationParameters(src.precision_param(), layer, isParamsPrecisionMandatory, parsedSuccessfully);
3284 }
3285 else { // quantization

Callers 15

ExtractDropoutParametersFunction · 0.85
ExtractReLUParametersFunction · 0.85
ExtractPoolingParametersFunction · 0.85
ExtractFCParametersFunction · 0.85
ExtractArgmaxParametersFunction · 0.85
ExtractSoftmaxParametersFunction · 0.85
ExtractCropParametersFunction · 0.85
ExtractConcatParametersFunction · 0.85
ExtractFlattenParametersFunction · 0.85
ExtractPermuteParametersFunction · 0.85

Calls 9

has_precision_paramMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected