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

Function ExtractSoftmaxParameters

software/xtract/caffe_network_parser.cpp:1739–1796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1737}
1738
1739void ExtractSoftmaxParameters(const caffe::LayerParameter& src, XGraph& graph)
1740{
1741 // Map the Caffe layer type to anonymoX layer type
1742 caffe::SoftmaxParameter src_parameter = src.softmax_param();
1743 mapStrStr::const_iterator it_type = CaffeLayerMap.find(src.type());
1744 string xlayerType = it_type->second;
1745
1746 // Parse the input/output connections
1747 checkNumberOfTopAndBottom(src, 1, 1);
1748
1749 // Create new XLayer
1750 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
1751
1752 // get AXIS [OPTIONAL : default = 1]
1753 dst->softmax_params->axis = src_parameter.has_axis() ? src_parameter.axis() : 1;
1754
1755 // Extract Precision Parameters
1756 bool success = ExtractPrecisionParameters(src, *dst, false);
1757 if(!success)
1758 graph.precMissLayers.push_back(src.name());
1759
1760 // Finally add the XLayer to graph
1761 graph.layers[src.name()] = dst;
1762
1763 // ----------------------------- Setup Blobs and Connections ----------------------- //
1764
1765 // Check bottom first. Make sure it is already registered in the Graph.blobs
1766 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false);
1767
1768 // Execution here reached means, bottom blob exists in graph. So update its fields
1769 XBlob* tmpBottom = it->second;
1770 dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom
1771 dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also
1772
1773 tmpBottom->consumers.push_back(dst->name); // Add convolution layer to bottom consumers
1774 tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data.
1775
1776 // Fill out nclasses & nboxes
1777 // nboxes is the dimension along the axis. nclasses is the rest.
1778 dst->softmax_params->nclasses = tmpBottom->shape.at(dst->softmax_params->axis);
1779 dst->softmax_params->nboxes = getSize(tmpBottom->shape)/tmpBottom->shape.at(dst->softmax_params->axis);
1780
1781 // Check top. Make sure it is not registered in the Graph.blobs
1782 it = graph.checkIfBlobExists(src.top(0), true, true);
1783
1784 // Execution reached here means, top blob doesn't exist, so create.
1785 XBlob* tmpTop = new XBlob(src.top(0));
1786 dst->top.push_back(nameIndex(tmpTop)); // Add top blob to current layer top list
1787
1788 // Update layer "top" info with top name and shape
1789 tmpTop->producers.push_back(dst->name); // Add current layer to top Producers list
1790 dst->computeOutputDim(); // Calculate the output blob shape
1791 tmpTop->producerDim.push_back(tmpTop->shape); // Add output blob shape to producerDim
1792 dst->topShape.push_back(tmpTop->shape); // Replicate bottom shape in Layer also
1793
1794 // Finally Register the top blob to graph
1795 graph.blobs[tmpTop->name] = tmpTop;
1796}

Callers 1

ExtractParametersFunction · 0.85

Calls 12

nameIndexClass · 0.85
getSizeFunction · 0.85
has_axisMethod · 0.80
axisMethod · 0.80
checkIfBlobExistsMethod · 0.80
findMethod · 0.45
typeMethod · 0.45
push_backMethod · 0.45
atMethod · 0.45
computeOutputDimMethod · 0.45

Tested by

no test coverage detected