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

Function ExtractXCustomParameters

software/xtract/caffe_network_parser.cpp:2909–2999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2907
2908
2909void ExtractXCustomParameters(const caffe::LayerParameter& src, XGraph& graph)
2910{
2911 // Map the Caffe layer type to anonymoX layer type
2912 caffe::XCustomParameter src_parameter = src.xcustom_param();
2913 string xlayerType = "XCustom";
2914
2915 // Create new XLayer
2916 XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0));
2917
2918 // Assign actual layer type
2919 dst->xcustom_params->type = src.type();
2920
2921 // Check if it is inPlace.
2922 int ntops = src.top_size();
2923 int nbottoms = src.bottom_size();
2924 ASSERT( (ntops > 0) && (nbottoms > 0), EP070,
2925 "There should be minimum one top & bottom blobs for layer " << src.name())
2926
2927 ASSERT( (ntops == 1), EP075,
2928 "Currently only one top blob is supported for user_defined_layer: " << src.name())
2929
2930 ELOG( (ntops == 1 && nbottoms == 1 && src.bottom(0) == src.top(0)), EP073,
2931 "bottom and top blobs should be separate for user_defined_layer : " << src.name() )
2932
2933 // Extract output dimensions [MANDATORY : Atleast one dimension should be given and it should be more than 0]
2934 ASSERT(src_parameter.top_dim_size() > 0, EP071,
2935 "Output dimension is not mentioned for user_defined_layer : " << src.name())
2936
2937 dst->xcustom_params->output_dim.insert( dst->xcustom_params->output_dim.end(),
2938 src_parameter.top_dim().begin(), src_parameter.top_dim().end());
2939
2940 ASSERT(getSize(dst->xcustom_params->output_dim) > 0, EP072,
2941 "Total dimesion should be greater than 0 for user_defined_layer : " << src.name())
2942
2943 // Extract all float arguments
2944 dst->xcustom_params->float_args.insert( dst->xcustom_params->float_args.end(),
2945 src_parameter.float_args().begin(), src_parameter.float_args().end());
2946
2947 // Extract all string arguments
2948 dst->xcustom_params->string_args.insert(dst->xcustom_params->string_args.end(),
2949 src_parameter.string_args().begin(), src_parameter.string_args().end());
2950
2951 // Finally add the XLayer to graph
2952 graph.layers[src.name()] = dst;
2953
2954 // ----------------------------- Setup Blobs and Connections ----------------------- //
2955
2956
2957 // Check bottom first. Make sure it is already registered in the Graph.blobs
2958 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false);
2959
2960 for(int i = 0; i<src.bottom_size(); i++)
2961 {
2962 // Check bottom first. Make sure it is already registered in the Graph.blobs
2963 map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(i), true, false);
2964
2965 // Execution here reached means, bottom blob exists in graph. So update its fields
2966 XBlob* tmpBottom = it->second;

Callers 1

ExtractParametersFunction · 0.85

Calls 15

getSizeFunction · 0.85
nameIndexClass · 0.85
top_sizeMethod · 0.80
bottom_sizeMethod · 0.80
top_dim_sizeMethod · 0.80
top_dimMethod · 0.80
float_argsMethod · 0.80
checkIfBlobExistsMethod · 0.80
typeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected