45 NodeID create_grouped_convolution(Graph &g,
const NodeParams ¶ms, NodeIdxPair
input,
NodeID weights,
NodeID bias,
68 std::vector<NodeIdxPair> convolution_outputs;
71 NodeParams group_params = params;
72 NodeID conv_nid = g.add_node<ConvolutionLayerNode>(
conv_info, 1, method, fast_math_hint);
73 g.add_connection(input_split, i, conv_nid, 0);
74 g.add_connection(weights_split, i, conv_nid, 1);
77 g.add_connection(bias_split, i, conv_nid, 2);
81 if(!group_params.name.empty())
87 INode *node = g.node(conv_nid);
89 node->set_common_node_parameters(group_params);
92 auto *conv_node = arm_compute::utils::cast::polymorphic_downcast<ConvolutionLayerNode *>(node);
93 conv_node->set_fused_activation(fused_act);
95 convolution_outputs.push_back({ conv_nid, 0 });
105 return "GroupedConvolutionMutator";
122 size_t total_nodes = g.
nodes().size();
125 for(
unsigned int i = 0; i < total_nodes; ++i)
128 if(node !=
nullptr && node->
type() ==
NodeType::ConvolutionLayer && arm_compute::utils::cast::polymorphic_downcast<ConvolutionLayerNode *>(node)->num_groups() != 1)
138 auto *conv_node = arm_compute::utils::cast::polymorphic_downcast<ConvolutionLayerNode *>(node);
145 const FastMathHint fast_math_hint = conv_node->fast_math_hint();
146 const unsigned int num_groups = conv_node->num_groups();
147 const NodeParams params = conv_node->common_node_params();
148 const Target assigned_target = conv_node->assigned_target();
151 ARM_COMPUTE_ERROR_ON(conv_node->input_edge(0) ==
nullptr || conv_node->input_edge(1) ==
nullptr);
152 const NodeID input_id = conv_node->input_edge(0)->producer()->id();
153 const NodeID weights_id = conv_node->input_edge(1)->producer()->id();
154 const NodeID bias_id = (conv_node->input_edge(2) !=
nullptr) ? conv_node->input_edge(2)->producer()->id() :
EmptyNodeID;
160 auto node_accessor = conv_node->output(0)->extract_accessor();
167 NodeID grouped_conv_id = create_grouped_convolution(g, params, { input_id, 0 }, weights_id, bias_id,
174 for(
auto &driving_node : driving_nodes)
176 g.
add_connection(grouped_conv_id, 0, driving_node.node_id, driving_node.index);
191 n->set_assigned_target(assigned_target);
TensorDescriptor get_tensor_descriptor(const Graph &g, TensorID tid)
Returns the tensor descriptor of a given tensor.
static NodeID add_split_node(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_splits, unsigned int axis=0)
Adds a split node to the graph.
void configure_tensor(Tensor *tensor)
Configures tensor.
std::vector< NodeIdxPair > get_driving_nodes(const INode &node)
Get the list of driving nodes of a given node.
Target assigned_target() const
Returns assigned target for this node.
std::string to_string(T &&value)
Convert integer and float values to string.
MutationType type() const override
Returns mutation type.
IDeviceBackend & get_backend(Target target)
Get a backend from the registry.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Activation Layer Information class.
static NodeID add_concatenate_node(Graph &g, NodeParams params, const std::vector< NodeIdxPair > &inputs, const descriptors::ConcatLayerDescriptor &concat_descriptor)
Adds a depth concatenate node to the graph.
void set_accessor(std::unique_ptr< ITensorAccessor > accessor)
Sets the backend tensor accessor.
Copyright (c) 2017-2021 Arm Limited.
std::vector< std::unique_ptr< Tensor > > & tensors()
Returns tensors of graph.
Tensor * output(size_t idx) const
Returns the tensor of a given output of the node.
virtual void mutate(Graph &g) override
Walk the graph and perform a specific mutation.
const unsigned int num_groups
bool remove_node(NodeID nid)
Remove the node with the given ID.
NodeID id() const
Returns node's ID.
Padding and stride information class.
EdgeID add_connection(NodeID source, size_t source_idx, NodeID sink, size_t sink_idx)
Adds a connection between two nodes.
static BackendRegistry & get()
Gets backend registry instance.
void for_each(F &&)
Base case of for_each.
FastMathHint
Enable or disable fast math for Convolution layer.
virtual Status validate_node(INode &node)=0
Validate a node.
const char * name() override
Returns mutator name.
const std::vector< NodeID > & nodes(NodeType type)
Returns graph input nodes.
MutationType
Mutation type.
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
const INode * node(NodeID id) const
Get node object given its id.
ConvolutionMethod
Supported Convolution layer methods.
Device backend interface.
virtual NodeType type() const =0
Returns node's type.
size_t get_dimension_idx(DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get index of a tensor's given dimension depending on its layout.