From 4d9687e70e2d71097cd43929d5f63377c3c44523 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 21 Oct 2020 18:33:36 +0100 Subject: Address RVO issue on some compilers Suppresses pessimizing-move during clang compilation as for some gcc toolchains RVO is not ensured until C++17 thus an explicit call to std::move might be required to avoid compilation error for non-copyable ojects (e.g. std::unique_ptr) Resolves: COMPMID-3599 Signed-off-by: Georgios Pinitas Change-Id: Ie3fa44fb0cf631655aecbeb6c82021a68f500a33 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4230 Reviewed-by: Giorgio Arena Reviewed-by: Michalis Spyrou Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- arm_compute/graph/backends/FunctionHelpers.h | 81 +++++++++++++--------------- 1 file changed, 37 insertions(+), 44 deletions(-) (limited to 'arm_compute/graph') diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 873957e6b7..ee5dc3e285 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -47,13 +47,6 @@ namespace backends { namespace detail { -// Address rule DR-9R5 (1579. Return by converting move constructor) -#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) -#define RETURN_UNIQUE_PTR(x) (x) -#else /* defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) */ -#define RETURN_UNIQUE_PTR(x) (std::move(x)) -#endif /* defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) */ - /** Returns backing tensor of a given tensor * * @tparam TargetInfo Target information @@ -128,7 +121,7 @@ std::unique_ptr create_activation_layer(ActivationLayerNode &node) << " InPlace : " << is_in_place_operation(input, output) << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Creates a backend argminmax layer function @@ -165,7 +158,7 @@ std::unique_ptr create_arg_min_max_layer(ArgMinMaxLayerNode &node) << " axis: " << axis << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend batch normalization layer function @@ -209,7 +202,7 @@ std::unique_ptr create_batch_normalization_layer(BatchNormalizationLa << " InPlace: " << is_in_place_operation(input, output) << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend batch normalization layer function @@ -266,7 +259,7 @@ std::unique_ptr create_fused_convolution_batch_normalization_layer(Fu << " Output shape: " << output->info()->tensor_shape() << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend fused depthwise convolution batch normalization layer function @@ -322,7 +315,7 @@ std::unique_ptr create_fused_depthwise_convolution_batch_normalizatio << " Output shape: " << output->info()->tensor_shape() << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend bounding box transform layer function @@ -360,7 +353,7 @@ std::unique_ptr create_bounding_box_transform_layer(BoundingBoxTransf << " BoundingBox Info img H: " << bbox_info.img_height() << " " << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend channel shuffle layer function @@ -395,7 +388,7 @@ std::unique_ptr create_channel_shuffle_layer(ChannelShuffleLayerNode << " Num groups: " << num_groups << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend layer concatenate function @@ -451,7 +444,7 @@ std::unique_ptr create_concatenate_layer(ConcatenateLaye << qss.str() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend convolution layer function @@ -542,7 +535,7 @@ std::unique_ptr create_convolution_layer(ConvolutionLayerNode &node, << qss.str() << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend deconvolution layer function @@ -648,7 +641,7 @@ std::unique_ptr create_depthwise_convolution_layer(DepthwiseConvoluti << qss.str() << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend depth to space layer function @@ -687,7 +680,7 @@ std::unique_ptr create_depth_to_space_layer(DepthToSpaceLayerNode &no << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend dequantize layer function @@ -726,7 +719,7 @@ std::unique_ptr create_dequantization_layer(DequantizationLayerNode & << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend detection output layer function * @@ -771,7 +764,7 @@ std::unique_ptr create_detection_output_layer(DetectionOutputLayerNod << " DetectionOutputLayer info: " << detect_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend detection post process layer function @@ -826,7 +819,7 @@ std::unique_ptr create_detection_post_process_layer(DetectionPostProc << " DetectionPostProcessLayer info: " << detect_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend element-wise operation layer function @@ -895,7 +888,7 @@ std::unique_ptr create_eltwise_layer(EltwiseLayerNode &node) << " Shape: " << input1->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend unary element-wise operation layer function @@ -943,7 +936,7 @@ std::unique_ptr create_unary_eltwise_layer(UnaryEltwiseLayerNode &nod << " Shape: " << input->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend flatten layer function @@ -981,7 +974,7 @@ std::unique_ptr create_flatten_layer(FlattenLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend fully connected layer function @@ -1037,7 +1030,7 @@ std::unique_ptr create_fully_connected_layer(FullyConnectedLayerNode << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend generate proposals layer function @@ -1086,7 +1079,7 @@ std::unique_ptr create_generate_proposals_layer(GenerateProposalsLaye << " Scores Out shape: " << scores_out->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend l2 normalization layer function @@ -1130,7 +1123,7 @@ std::unique_ptr create_l2_normalize_layer(L2NormalizeLayerNode &node, << " Epsilon: " << epsilon << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend normalization layer function @@ -1172,7 +1165,7 @@ std::unique_ptr create_normalization_layer(NormalizationLayerNode &no << " Normalization info: " << norm_info.type() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend normalize planar YUV layer function @@ -1212,7 +1205,7 @@ std::unique_ptr create_normalize_planar_yuv_layer(NormalizePlanarYUVL << " Shape: " << input->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend pad layer function @@ -1251,7 +1244,7 @@ std::unique_ptr create_pad_layer(PadLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend permute layer function @@ -1290,7 +1283,7 @@ std::unique_ptr create_permute_layer(PermuteLayerNode &node) << " Permutation vector: " << perm << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend pooling layer function @@ -1329,7 +1322,7 @@ std::unique_ptr create_pooling_layer(PoolingLayerNode &node) << " Pooling info: " << pool_info.pool_type << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend PRelu layer function @@ -1367,7 +1360,7 @@ std::unique_ptr create_prelu_layer(PReluLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend print layer function @@ -1438,7 +1431,7 @@ std::unique_ptr create_priorbox_layer(PriorBoxLayerNode &node) << " PriorBoxLayer info: " << prior_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend quantization layer function @@ -1475,7 +1468,7 @@ std::unique_ptr create_quantization_layer(QuantizationLayerNode &node << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend reduction operation layer function @@ -1519,7 +1512,7 @@ std::unique_ptr create_reduction_operation_layer(ReductionLayerNode & << " Keep dimensions:" << keep_dims << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend reorg layer function @@ -1556,7 +1549,7 @@ std::unique_ptr create_reorg_layer(ReorgLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend reshape layer function @@ -1593,7 +1586,7 @@ std::unique_ptr create_reshape_layer(ReshapeLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend resize layer function @@ -1632,7 +1625,7 @@ std::unique_ptr create_resize_layer(ResizeLayerNode &node) << " Interpolation: " << policy << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend ROI align layer function @@ -1677,7 +1670,7 @@ std::unique_ptr create_roi_align_layer(ROIAlignLayerNode &node) << " ROIPooling height: " << pool_info.pooled_height() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend slice layer function @@ -1714,7 +1707,7 @@ std::unique_ptr create_slice_layer(SliceLayerNode &node) << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend softmax layer function @@ -1753,7 +1746,7 @@ std::unique_ptr create_softmax_layer(SoftmaxLayerNode &node, GraphCon << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend layer stack function @@ -1796,7 +1789,7 @@ std::unique_ptr create_stack_layer(StackLayerNode &node) << " Axis: " << axis << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend slice layer function @@ -1838,7 +1831,7 @@ std::unique_ptr create_strided_slice_layer(StridedSliceLayerNode &nod << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } } // namespace detail } // namespace backends -- cgit v1.2.1