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

Function ExtractPoolingParameters

software/xtract/caffe_network_parser.cpp:1462–1605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1460}
1461
1462void ExtractPoolingParameters(const caffe::LayerParameter& src, XGraph& graph)
1463{
1464 // Map the Caffe layer type to anonymoX layer type
1465 caffe::PoolingParameter src_parameter = src.pooling_param();
1466 mapStrStr::const_iterator it_type = CaffeLayerMap.find(src.type());
1467 string xlayerType = it_type->second;
1468
1469 // Parse the input/output connections
1470 checkNumberOfTopAndBottom(src, 1, 1);
1471
1472 // Create new XLayer
1473 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
1474
1475 // Get POOLING_TYPE [OPTIONAL, caffe default = MAX]
1476 dst->pool_params->PoolType = (src_parameter.has_pool()) ? (PoolingType)src_parameter.pool() : MAX;
1477
1478 // Check GLOBAL POOLING
1479 bool global_pooling = (src_parameter.has_global_pooling() && src_parameter.global_pooling() == true) ? true : false;
1480
1481 // Get FILTER SIZE [MANDATORY if it is not a GLOBAL POOLING]
1482 if(global_pooling == false)
1483 {
1484 if (src_parameter.has_kernel_h() || src_parameter.has_kernel_w())
1485 {
1486 ELOG ( (src_parameter.has_kernel_size()),
1487 EP161,
1488 "Mention either kernel_size or kernel_h/kernel_w for layer " << src.name() << ". Not both. !!")
1489 ASSERT((src_parameter.has_kernel_h() && src_parameter.has_kernel_w()),
1490 EP162,
1491 "Mention both kernel_h and kernel_w for layer " << src.name() << ". Or use kernel_size.")
1492 dst->pool_params->kernel_h = src_parameter.kernel_h();
1493 dst->pool_params->kernel_w = src_parameter.kernel_w();
1494 }
1495 else
1496 {
1497 ASSERT((src_parameter.has_kernel_size()),
1498 EP163, "kernel_size is not specified in the Pooling layer : " << src.name())
1499 dst->pool_params->kernel_h = src_parameter.kernel_size();
1500 dst->pool_params->kernel_w = src_parameter.kernel_size();
1501 }
1502 }
1503 else
1504 {
1505 dst->pool_params->kernel_h = 0;
1506 dst->pool_params->kernel_w = 0;
1507 }
1508
1509 // Get PAD [DEFAULT = 0]
1510 if (src_parameter.has_pad_h() || src_parameter.has_pad_w())
1511 {
1512 ELOG ( (src_parameter.has_pad()),
1513 EP165,
1514 "Mention either pad or pad_h/pad_w for layer " << src.name() << ". Not both. !!")
1515 ASSERT((src_parameter.has_pad_h() && src_parameter.has_pad_w()),
1516 EP166,
1517 "Mention both pad_h and pad_w for layer " << src.name() << ". Or use pad.")
1518 dst->pool_params->pad_h = src_parameter.pad_h();
1519 dst->pool_params->pad_w = src_parameter.pad_w();

Callers 1

ExtractParametersFunction · 0.85

Calls 15

nameIndexClass · 0.85
has_poolMethod · 0.80
poolMethod · 0.80
has_global_poolingMethod · 0.80
global_poolingMethod · 0.80
has_kernel_hMethod · 0.80
has_kernel_wMethod · 0.80
has_kernel_sizeMethod · 0.80
kernel_hMethod · 0.80
kernel_wMethod · 0.80
kernel_sizeMethod · 0.80

Tested by

no test coverage detected