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

Function ExtractDropoutParameters

software/xtract/caffe_network_parser.cpp:1318–1390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1316
1317
1318void ExtractDropoutParameters(const caffe::LayerParameter& src, XGraph& graph)
1319{
1320 // Map the Caffe layer type to anonymoX layer type
1321 caffe::DropoutParameter src_parameter = src.dropout_param();
1322 mapStrStr::const_iterator type_it = CaffeLayerMap.find(src.type());
1323 string xlayerType = type_it->second;
1324
1325 // Create new XLayer
1326 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
1327
1328 // Parse the input/output connections
1329 checkNumberOfTopAndBottom(src, 1, 1);
1330
1331 // Check if it is inPlace.
1332 dst->dropout_params->inPlace = src.bottom(0) == src.top(0) ? true : false;
1333 dst->inPlace = src.bottom(0) == src.top(0) ? true : false;
1334
1335 // Get Dropout Ratio
1336 dst->dropout_params->dropout_ratio = src_parameter.dropout_ratio();
1337
1338 // Extract Precision Parameters
1339 bool success = ExtractPrecisionParameters(src, *dst);
1340 if(!success)
1341 graph.precMissLayers.push_back(src.name());
1342
1343 // Finally add the XLayer to graph
1344 graph.layers[src.name()] = dst;
1345
1346 // ----------------------------- Setup Blobs and Connections ----------------------- //
1347
1348
1349 // Check bottom first. Make sure it is already registered in the Graph.blobs
1350 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false);
1351
1352 // Execution here reached means, bottom blob exists in graph. So update its fields
1353 XBlob* tmpBottom = it->second;
1354 dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom
1355 dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also
1356
1357 tmpBottom->consumers.push_back(dst->name); // Add layer to bottom consumers
1358 tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data.
1359
1360 // Here, things are a little different because of the inplace operation
1361 if(dst->dropout_params->inPlace == false)
1362 {
1363 // Check top. Make sure it is not registered in the Graph.blobs
1364 it = graph.checkIfBlobExists(src.top(0), true, true);
1365
1366 // Execution reached here means, top blob doesn't exist, so create.
1367 XBlob* tmpTop = new XBlob(src.top(0));
1368 dst->top.push_back(nameIndex(tmpTop)); // Add top blob to current layer top list
1369
1370 // Update layer "top" info with top name and shape
1371 tmpTop->producers.push_back(dst->name); // Add current layer to top Producers list
1372 dst->computeOutputDim(); // Calculate the output blob shape
1373 tmpTop->producerDim.push_back(tmpTop->shape); // Add output blob shape to producerDim
1374 dst->topShape.push_back(tmpTop->shape); // Replicate bottom shape in Layer also
1375

Callers 1

ExtractParametersFunction · 0.85

Calls 9

nameIndexClass · 0.85
dropout_ratioMethod · 0.80
checkIfBlobExistsMethod · 0.80
findMethod · 0.45
typeMethod · 0.45
push_backMethod · 0.45
computeOutputDimMethod · 0.45

Tested by

no test coverage detected