| 827 | } |
| 828 | |
| 829 | void extractXCustomTrainedData(XGraph* graph, const string& layerName, const caffe::NetParameter* Net, |
| 830 | const map<string, int>* layerIndex) |
| 831 | { |
| 832 | XLayer* tmpXlayer = graph->layers[layerName]; |
| 833 | map<string, int>::const_iterator modelLayer_it = layerIndex->find(layerName); |
| 834 | |
| 835 | // If the layer name not found in binFile, |
| 836 | // If it is a supported layer, throw error |
| 837 | // Else if it is a custom layer, return |
| 838 | |
| 839 | if(modelLayer_it == layerIndex->end()) |
| 840 | { |
| 841 | if(tmpXlayer->type != "XCustom") |
| 842 | { |
| 843 | cerr << "[EP035] Layer " << layerName << " is not found in the caffemodel file. " << endl; |
| 844 | exit(-1); |
| 845 | } |
| 846 | else |
| 847 | { |
| 848 | return; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | // All is well, Start extracting |
| 853 | // Get the layer from caffemodel |
| 854 | int loc = modelLayer_it->second; |
| 855 | const caffe::LayerParameter& binLayer = Net->layer(loc); |
| 856 | LOG( binLayer.type() != tmpXlayer->xcustom_params->type, EP074, |
| 857 | "Layer types not matching in deploy file and caffemodel file for user_defined_layer: " |
| 858 | << layerName << " : " << binLayer.type() << " v/s " << tmpXlayer->xcustom_params->type ) |
| 859 | |
| 860 | for(int i=0; i<binLayer.blobs_size(); ++i) |
| 861 | { |
| 862 | tmpXlayer->xcustom_params->params.push_back(extractBlobToVector(binLayer.blobs(i))); |
| 863 | tmpXlayer->xcustom_params->params_dims.push_back(getBlobDim(binLayer.blobs(i))); |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | // A function to return the dimension of a caffe blob |
| 868 | vector<int> getBlobDim(const caffe::BlobProto& blob) |
no test coverage detected