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

Function ExtractScaleParameters

software/xtract/caffe_network_parser.cpp:2735–2817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2733}
2734
2735void ExtractScaleParameters(const caffe::LayerParameter& src, XGraph& graph)
2736{
2737 // Map the Caffe layer type to anonymoX layer type
2738 caffe::ScaleParameter src_parameter = src.scale_param();
2739 mapStrStr::const_iterator type_it = CaffeLayerMap.find(src.type());
2740 string xlayerType = type_it->second;
2741
2742 // Create new XLayer
2743 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
2744
2745 // Parse the input/output connections
2746 checkNumberOfTopAndBottom(src, 1, 1);
2747
2748 // Check if it is inPlace.
2749 dst->scale_params->inPlace = src.bottom(0) == src.top(0) ? true : false;
2750 dst->inPlace = src.bottom(0) == src.top(0) ? true : false;
2751
2752 // Check if bias there or not
2753 dst->scale_params->has_bias = src_parameter.has_bias_term() ? src_parameter.bias_term() : false;
2754
2755 // Get axis [default: 1]
2756 // TODO : Ark : Currently only axis=1 is allowed
2757 dst->scale_params->axis = src_parameter.has_axis() ? src_parameter.axis() : 1;
2758 ASSERT(dst->scale_params->axis == 1, EP062, "Currently, axis should be 1 in Scale Layer")
2759
2760 // Get num_axes [default: 1]
2761 // TODO : Ark : Currently only num_axes=1 is allowed
2762 dst->scale_params->num_axes = src_parameter.has_num_axes() ? src_parameter.num_axes() : 1;
2763 ASSERT(dst->scale_params->num_axes == 1, EP063, "Currently, num_axes should be 1 in Scale Layer")
2764
2765 // Finally add the XLayer to graph
2766 graph.layers[src.name()] = dst;
2767
2768 // ----------------------------- Setup Blobs and Connections ----------------------- //
2769
2770
2771 // Check bottom first. Make sure it is already registered in the Graph.blobs
2772 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false);
2773
2774 // Execution here reached means, bottom blob exists in graph. So update its fields
2775 XBlob* tmpBottom = it->second;
2776 dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom
2777 tmpBottom->consumers.push_back(dst->name); // Add layer to bottom consumers
2778 tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data.
2779 dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also
2780
2781 // Here, things are a little different because of the inplace operation
2782 if(dst->scale_params->inPlace == false)
2783 {
2784 // Check top. Make sure it is not registered in the Graph.blobs
2785 it = graph.checkIfBlobExists(src.top(0), true, true);
2786
2787 // Execution reached here means, top blob doesn't exist, so create.
2788 XBlob* tmpTop = new XBlob(src.top(0));
2789 dst->top.push_back(nameIndex(tmpTop)); // Add top blob to current layer top list
2790
2791 // Update layer "top" info with top name and shape
2792 tmpTop->producers.push_back(dst->name); // Add current layer to top Producers list

Callers 1

ExtractParametersFunction · 0.85

Calls 14

nameIndexClass · 0.85
has_bias_termMethod · 0.80
bias_termMethod · 0.80
has_axisMethod · 0.80
axisMethod · 0.80
has_num_axesMethod · 0.80
num_axesMethod · 0.80
checkIfBlobExistsMethod · 0.80
findMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected