| 118 | } |
| 119 | |
| 120 | void GroupedConvolutionMutator::mutate(Graph &g) |
| 121 | { |
| 122 | // Early exit if no Convolution layers exist in graph |
| 123 | if (g.nodes(NodeType::ConvolutionLayer).empty()) |
| 124 | { |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | // Total nodes |
| 129 | size_t total_nodes = g.nodes().size(); |
| 130 | |
| 131 | // Iterate over convolution nodes |
| 132 | for (unsigned int i = 0; i < total_nodes; ++i) |
| 133 | { |
| 134 | INode *node = g.node(i); |
| 135 | if (node != nullptr && node->type() == NodeType::ConvolutionLayer && |
| 136 | arm_compute::utils::cast::polymorphic_downcast<ConvolutionLayerNode *>(node)->num_groups() != 1) |
| 137 | { |
| 138 | // Validate node |
| 139 | backends::IDeviceBackend &backend = backends::BackendRegistry::get().get_backend(node->assigned_target()); |
| 140 | Status status = backend.validate_node(*node); |
| 141 | |
| 142 | // If grouped convolution is not supported |
| 143 | if (!bool(status)) |
| 144 | { |
| 145 | // Down-cast node |
| 146 | auto *conv_node = arm_compute::utils::cast::polymorphic_downcast<ConvolutionLayerNode *>(node); |
| 147 | |
| 148 | // Get internal convolution info |
| 149 | // TODO (geopin01) : Create a descriptor or a clone interface |
| 150 | const PadStrideInfo conv_info = conv_node->convolution_info(); |
| 151 | const ConvolutionMethod conv_method = conv_node->convolution_method(); |
| 152 | const ActivationLayerInfo fused_act_info = conv_node->fused_activation(); |
| 153 | const FastMathHint fast_math_hint = conv_node->fast_math_hint(); |
| 154 | const unsigned int num_groups = conv_node->num_groups(); |
| 155 | const NodeParams params = conv_node->common_node_params(); |
| 156 | const Target assigned_target = conv_node->assigned_target(); |
| 157 | |
| 158 | // Extract node ids |
| 159 | ARM_COMPUTE_ERROR_ON(conv_node->input_edge(0) == nullptr || conv_node->input_edge(1) == nullptr); |
| 160 | const NodeID input_id = conv_node->input_edge(0)->producer()->id(); |
| 161 | const NodeID weights_id = conv_node->input_edge(1)->producer()->id(); |
| 162 | const NodeID bias_id = |
| 163 | (conv_node->input_edge(2) != nullptr) ? conv_node->input_edge(2)->producer()->id() : EmptyNodeID; |
| 164 | |
| 165 | // Get driving nodes |
| 166 | std::vector<NodeIdxPair> driving_nodes = get_driving_nodes(*node); |
| 167 | |
| 168 | // Extract activation node accessor if any |
| 169 | auto node_accessor = conv_node->output(0)->extract_accessor(); |
| 170 | |
| 171 | // Current max tensor and node id |
| 172 | TensorID latest_tid = g.tensors().size(); |
| 173 | NodeID latest_nid = g.nodes().size(); |
| 174 | |
| 175 | // Create grouped convolution node |
| 176 | NodeID grouped_conv_id = |
| 177 | create_grouped_convolution(g, params, {input_id, 0}, weights_id, bias_id, conv_info, conv_method, |
nothing calls this directly
no test coverage detected