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

Function ExtractPowerParameters

software/xtract/caffe_network_parser.cpp:2820–2906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2818
2819
2820void ExtractPowerParameters(const caffe::LayerParameter& src, XGraph& graph)
2821{
2822 // Map the Caffe layer type to anonymoX layer type
2823 caffe::PowerParameter src_parameter = src.power_param();
2824 mapStrStr::const_iterator type_it = CaffeLayerMap.find(src.type());
2825 string xlayerType = type_it->second;
2826
2827 // Create new XLayer
2828 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
2829
2830 // Parse the input/output connections
2831 checkNumberOfTopAndBottom(src, 1, 1);
2832
2833 // Check if it is inPlace.
2834 dst->power_params->inPlace = src.bottom(0) == src.top(0) ? true : false;
2835 dst->inPlace = src.bottom(0) == src.top(0) ? true : false;
2836
2837 // Get power [default: 1.0]
2838 // TODO : Ark : Currently only power=1.0 is allowed
2839 dst->power_params->power = src_parameter.has_power() ? src_parameter.power() : 1.0;
2840 ASSERT(dst->power_params->power == 1.0, EP072, "Current version of xfDNN supports only power = 1.0 in Power Layer")
2841
2842 // Get scale [default: 1]
2843 // TODO : Ark : Currently only scale=1 is allowed
2844 dst->power_params->scale = src_parameter.has_scale() ? src_parameter.scale() : 1.0;
2845 ASSERT(dst->power_params->scale == -1.0, EP073, "Current version of xfDNN supports only scale = -1.0 in Power Layer")
2846
2847 // Get shift [default: 1]
2848 // TODO : Ark : Currently only shift = 0.0 is allowed
2849 dst->power_params->shift = src_parameter.has_shift() ? src_parameter.shift() : 0.0;
2850 ASSERT(dst->power_params->shift == 0.0, EP074, "Current version of xfDNN supports only shift = 0.0 in Power Layer")
2851
2852 // Extract Precision Parameters
2853 // ExtractPrecisionParameters(src, *dst, false);
2854
2855 // Finally add the XLayer to graph
2856 graph.layers[src.name()] = dst;
2857
2858 // ----------------------------- Setup Blobs and Connections ----------------------- //
2859
2860
2861 // Check bottom first. Make sure it is already registered in the Graph.blobs
2862 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false);
2863
2864 // Execution here reached means, bottom blob exists in graph. So update its fields
2865 XBlob* tmpBottom = it->second;
2866 dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom
2867 tmpBottom->consumers.push_back(dst->name); // Add layer to bottom consumers
2868 tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data.
2869 dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also
2870
2871 // Here, things are a little different because of the inplace operation
2872 if(dst->power_params->inPlace == false)
2873 {
2874 // Check top. Make sure it is not registered in the Graph.blobs
2875 it = graph.checkIfBlobExists(src.top(0), true, true);
2876
2877 // Execution reached here means, top blob doesn't exist, so create.

Callers 1

ExtractParametersFunction · 0.85

Calls 14

nameIndexClass · 0.85
has_powerMethod · 0.80
powerMethod · 0.80
has_scaleMethod · 0.80
scaleMethod · 0.80
has_shiftMethod · 0.80
shiftMethod · 0.80
checkIfBlobExistsMethod · 0.80
findMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected