| 2907 | |
| 2908 | |
| 2909 | void 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; |
no test coverage detected