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

Function ExtractEltwiseParameters

software/xtract/caffe_network_parser.cpp:2590–2654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2588}
2589
2590void ExtractEltwiseParameters(const caffe::LayerParameter& src, XGraph& graph)
2591{
2592 // Map the Caffe layer type to anonymoX layer type
2593 caffe::EltwiseParameter src_parameter = src.eltwise_param();
2594 mapStrStr::const_iterator it_type = CaffeLayerMap.find(src.type());
2595 string xlayerType = it_type->second;
2596
2597 // Parse the input/output connections
2598 checkNumberOfTopAndBottom(src, 2, 1);
2599
2600 // Create new XLayer
2601 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
2602
2603 // Get Op Type [OPTIONAL, DEFAULT=SUM]
2604 dst->eltwise_params->type = (src_parameter.has_operation()) ? (EltOpType)src_parameter.operation() : (EltOpType)ELT_SUM;
2605
2606 // Currently only SUM/PROD is supported
2607 ASSERT ((dst->eltwise_params->type == ELT_SUM) || (dst->eltwise_params->type == ELT_PROD), EP061,
2608 "For Eltwise layer, only SUM and PROD operation is allowed")
2609
2610 // Get coeff. TODO : ARK: Currently coeff is not supported
2611 ASSERT(src_parameter.coeff().size() == 0, EP062, "Coeff for Eltwise layer is not currently supported")
2612
2613
2614 // Finally add the XLayer to graph
2615 graph.layers[src.name()] = dst;
2616
2617 // ----------------------------- Setup Blobs and Connections ----------------------- //
2618
2619 // Crop has two bottom, so iterate through them
2620
2621 for(int i = 0; i<src.bottom_size(); i++)
2622 {
2623 // Check bottom first. Make sure it is already registered in the Graph.blobs
2624 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(i), true, false);
2625
2626 // Execution here reached means, bottom blob exists in graph. So update its fields
2627 XBlob* tmpBottom = it->second;
2628 dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom
2629 dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also
2630 tmpBottom->consumers.push_back(dst->name); // Add convolution layer to bottom consumers
2631 tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data.
2632 }
2633
2634 // Check top. Make sure it is not registered in the Graph.blobs
2635 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.top(0), true, true);
2636
2637 // Execution reached here means, top blob doesn't exist, so create.
2638 XBlob* tmpTop = new XBlob(src.top(0));
2639 dst->top.push_back(nameIndex(tmpTop)); // Add top blob to current layer top list
2640
2641 // Update layer "top" info with top name and shape
2642 tmpTop->producers.push_back(dst->name); // Add current layer to top Producers list
2643 dst->computeOutputDim(); // Calculate the output blob shape
2644 tmpTop->producerDim.push_back(tmpTop->shape); // Add output blob shape to producerDim
2645 dst->topShape.push_back(tmpTop->shape); // Replicate bottom shape in Layer also
2646
2647 // Finally Register the top blob to graph

Callers 1

ExtractParametersFunction · 0.85

Calls 13

nameIndexClass · 0.85
has_operationMethod · 0.80
operationMethod · 0.80
coeffMethod · 0.80
bottom_sizeMethod · 0.80
checkIfBlobExistsMethod · 0.80
findMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected