| 2004 | } |
| 2005 | |
| 2006 | void ExtractPermuteParameters(const caffe::LayerParameter& src, XGraph& graph) |
| 2007 | { |
| 2008 | // Map the Caffe layer type to anonymoX layer type |
| 2009 | caffe::PermuteParameter src_parameter = src.permute_param(); |
| 2010 | mapStrStr::const_iterator it_type = CaffeLayerMap.find(src.type()); |
| 2011 | string xlayerType = it_type->second; |
| 2012 | |
| 2013 | // Parse the input/output connections |
| 2014 | checkNumberOfTopAndBottom(src, 1, 1); |
| 2015 | |
| 2016 | // Create new XLayer |
| 2017 | XLayer* dst = new XLayer(src.name(), xlayerType, src.top(0)); |
| 2018 | |
| 2019 | // Get ORDER [REPEATED] |
| 2020 | vector<int> tmp_order; |
| 2021 | tmp_order.resize(src_parameter.order_size()); |
| 2022 | copy(src_parameter.order().begin(), src_parameter.order().end(), tmp_order.begin()); |
| 2023 | // TODO : @ARK : Currently we support an order (0, 2, 3, 1) only. This kernel should be generic for any order. |
| 2024 | if( (tmp_order.size() != 4) || |
| 2025 | (tmp_order.at(0) != 0) || |
| 2026 | (tmp_order.at(1) != 2) || |
| 2027 | (tmp_order.at(2) != 3) || |
| 2028 | (tmp_order.at(3) != 1) ) |
| 2029 | { |
| 2030 | cerr << "[EP041] Current version support permute layer with order (0, 2, 3, 1) only. Given order : " << TensorDimToString(tmp_order, ", ") << endl; |
| 2031 | exit(-1); |
| 2032 | } |
| 2033 | else |
| 2034 | { |
| 2035 | dst->permute_params->order = tmp_order; |
| 2036 | } |
| 2037 | |
| 2038 | // Extract Precision Parameters |
| 2039 | bool success = ExtractPrecisionParameters(src, *dst, false); |
| 2040 | if(!success) |
| 2041 | graph.precMissLayers.push_back(src.name()); |
| 2042 | |
| 2043 | // Finally add the XLayer to graph |
| 2044 | graph.layers[src.name()] = dst; |
| 2045 | |
| 2046 | // ----------------------------- Setup Blobs and Connections ----------------------- // |
| 2047 | |
| 2048 | // Check bottom first. Make sure it is already registered in the Graph.blobs |
| 2049 | map<string, XBlob*>::iterator it = graph.checkIfBlobExists(src.bottom(0), true, false); |
| 2050 | |
| 2051 | // Execution here reached means, bottom blob exists in graph. So update its fields |
| 2052 | XBlob* tmpBottom = it->second; |
| 2053 | dst->bottom.push_back(nameIndex(tmpBottom)); // Add bottom to XLayer.bottom |
| 2054 | dst->bottomShape.push_back(tmpBottom->shape); // Replicate bottom shape in Layer also |
| 2055 | |
| 2056 | tmpBottom->consumers.push_back(dst->name); // Add convolution layer to bottom consumers |
| 2057 | tmpBottom->consumerDim.push_back(tmpBottom->shape); // and consumer uses the full bottom data. |
| 2058 | |
| 2059 | // Check top. Make sure it is not registered in the Graph.blobs |
| 2060 | it = graph.checkIfBlobExists(src.top(0), true, true); |
| 2061 | |
| 2062 | // Execution reached here means, top blob doesn't exist, so create. |
| 2063 | XBlob* tmpTop = new XBlob(src.top(0)); |
no test coverage detected