MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / mutate

Method mutate

src/graph/mutators/NodeFusionMutator.cpp:379–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379void NodeFusionMutator::mutate(Graph &g)
380{
381 // Supported activations when fusing
382 const std::set<Activation> supported_fused_activations = {
383 Activation::ABS, Activation::BOUNDED_RELU, Activation::ELU,
384 Activation::HARD_SWISH, Activation::IDENTITY, Activation::LEAKY_RELU,
385 Activation::LINEAR, Activation::LOGISTIC, Activation::LU_BOUNDED_RELU,
386 Activation::RELU, Activation::SOFT_RELU, Activation::SQRT,
387 Activation::SQUARE, Activation::TANH};
388
389 // Preconditions
390 auto empty_prec = [](INode &) { return true; };
391 auto cl_target_prec = [](INode &n) { return n.assigned_target() == Target::CL; };
392 auto qs8_prec = [&g](INode &n)
393 {
394 ARM_COMPUTE_ERROR_ON(n.output(0) == nullptr);
395
396 const auto output_edge_id = *n.output_edges().begin();
397 const auto output_edge = g.edge(output_edge_id);
398 // To perform fusion the two nodes must have same output quantization information
399 const bool same_qinfo = n.output(0)->desc().quant_info == output_edge->producer()->output(0)->desc().quant_info;
400 const bool output_qasymm8 = n.output(0)->desc().data_type == DataType::QASYMM8;
401
402 return (output_qasymm8 && same_qinfo) || !output_qasymm8;
403 };
404
405 // Fusion mutations
406
407 detail::fuse_layer<PadLayerNode, ConvolutionLayerNode>(g, empty_prec,
408 detail::fuse_pad_with_convolution<ConvolutionLayerNode>);
409 detail::fuse_layer<PadLayerNode, DepthwiseConvolutionLayerNode>(
410 g, empty_prec, detail::fuse_pad_with_convolution<DepthwiseConvolutionLayerNode>);
411 detail::fuse_layer<BatchNormalizationLayerNode, ActivationLayerNode>(
412 g, empty_prec, detail::fuse_node_with_activation<BatchNormalizationLayerNode>, supported_fused_activations);
413 detail::fuse_layer<ConvolutionLayerNode, ActivationLayerNode>(
414 g, empty_prec, detail::fuse_node_with_activation<ConvolutionLayerNode>, supported_fused_activations);
415 detail::fuse_layer<DepthwiseConvolutionLayerNode, ActivationLayerNode>(
416 g, qs8_prec, detail::fuse_node_with_activation<DepthwiseConvolutionLayerNode>, supported_fused_activations);
417 detail::fuse_layer<FullyConnectedLayerNode, ActivationLayerNode>(
418 g, empty_prec, detail::fuse_node_with_activation<FullyConnectedLayerNode>, supported_fused_activations);
419 detail::fuse_layer<EltwiseLayerNode, ActivationLayerNode>(
420 g, cl_target_prec, detail::fuse_node_with_activation<EltwiseLayerNode>, supported_fused_activations);
421 // The fusion of BatchNormalizationLayer must occur after the fusion of ActivationLayer. Because FusedConvolutionBatchNormalizationNode assumes the BatchNormalization is already fused with activation, if any
422 detail::fuse_layer<ConvolutionLayerNode, BatchNormalizationLayerNode>(
423 g, empty_prec, detail::fuse_convolution_with_batch_normalization);
424 detail::fuse_layer<DepthwiseConvolutionLayerNode, BatchNormalizationLayerNode>(
425 g, empty_prec, detail::fuse_depthwise_convolution_with_batch_normalization);
426}
427} // namespace graph
428} // namespace arm_compute

Callers 3

run_allMethod · 0.45
run_typeMethod · 0.45
run_indexMethod · 0.45

Calls 5

assigned_targetMethod · 0.80
outputMethod · 0.80
edgeMethod · 0.80
producerMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected