| 36 | { |
| 37 | template <typename T> |
| 38 | void add_convolution_layer_data(DataLayerVisitor::LayerData &layer_data, T &node) |
| 39 | { |
| 40 | PadStrideInfo ps_info = node.convolution_info(); |
| 41 | DataLayout layout = node.output(0)->desc().layout; |
| 42 | // Add data layout |
| 43 | layer_data["data_layout"] = to_string(layout); |
| 44 | // Add padding info |
| 45 | std::ostringstream padding; |
| 46 | padding << "[" << to_string(ps_info.pad_left()) << "," << to_string(ps_info.pad_top()) << "," |
| 47 | << to_string(ps_info.pad_bottom()) << "," << to_string(ps_info.pad_right()) << "]"; |
| 48 | |
| 49 | layer_data["pad"] = padding.str(); |
| 50 | |
| 51 | // Add stride info |
| 52 | std::ostringstream stride; |
| 53 | stride << "[" << to_string(ps_info.stride().first) << "," << to_string(ps_info.stride().second) << "]"; |
| 54 | |
| 55 | layer_data["stride"] = stride.str(); |
| 56 | |
| 57 | // Add dilation info |
| 58 | // graph api does not support dilation > 1 |
| 59 | layer_data["dilation"] = "[1,1]"; |
| 60 | |
| 61 | // Add bias enabled? |
| 62 | // Assumes three inputs (input, weights, bias) |
| 63 | std::string bias_enabled = node.input(2) == nullptr ? "0" : "1"; |
| 64 | layer_data["bias_enabled"] = bias_enabled; |
| 65 | |
| 66 | // Change input names for weights / bias (if applicable) |
| 67 | // Assumes input(1) is weights and input(2) is bias |
| 68 | if (layer_data.count("input_shape1")) |
| 69 | { |
| 70 | layer_data["weights_shape"] = layer_data["input_shape1"]; |
| 71 | layer_data.erase("input_shape1"); |
| 72 | } |
| 73 | if (layer_data.count("input_shape2")) |
| 74 | { |
| 75 | layer_data["bias_shape"] = layer_data["input_shape2"]; |
| 76 | layer_data.erase("input_shape2"); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | template <typename T> |
| 81 | void add_convolution_layer_method(DataLayerVisitor::LayerData &layer_data, T &node) |
nothing calls this directly
no test coverage detected