From f52cd78acdedc9b4e2342daf2ca65578a6da28e1 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 25 Mar 2019 14:06:14 +0000 Subject: COMPMID-1995: Minor code fixes. -Remove FIXMEs and link to tickets. -Pass large object by const reference. -Implement copy assignment operator for Window. Change-Id: I975223ac42ec424f153569a8c963f29e6b86ad29 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/899 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- arm_compute/core/Window.h | 17 +++++++++++++++-- arm_compute/core/Window.inl | 14 +++++++++++++- arm_compute/graph/GraphBuilder.h | 4 ++-- arm_compute/graph/frontend/Layers.h | 4 ++-- examples/graph_mobilenet.cpp | 4 ++-- examples/graph_mobilenet_v2.cpp | 2 +- examples/graph_ssd_mobilenet.cpp | 4 ++-- src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp | 6 +++--- src/graph/GraphBuilder.cpp | 4 ++-- src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp | 2 +- utils/GraphUtils.h | 6 +++--- utils/TypePrinter.h | 1 - utils/command_line/CommandLineParser.h | 4 ++-- 13 files changed, 48 insertions(+), 24 deletions(-) diff --git a/arm_compute/core/Window.h b/arm_compute/core/Window.h index 73c8d4385b..a56227996b 100644 --- a/arm_compute/core/Window.h +++ b/arm_compute/core/Window.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -56,6 +56,13 @@ public: * @param[in] src Copy the values from src to a new object */ Window(const Window &src); + /** Copy assignment operator + * + * @param[in] rhs Copy the values from rhs to the current object + * + * @return Reference to the updated object + */ + Window &operator=(const Window &rhs); /** Describe one of the image's dimensions with a start, end and step. * @@ -384,6 +391,12 @@ public: { return broadcast_if_dimension_le_one(info.tensor_shape()); } + /** Friend function that swaps the contents of two windows + * + * @param[in] lhs First window to swap. + * @param[in] rhs Second window to swap. + */ + friend void swap(Window &lhs, Window &rhs); private: /** First slice of the window @@ -407,6 +420,6 @@ private: private: std::array _dims; }; -} +} // namespace arm_compute #include "Window.inl" #endif /*__ARM_COMPUTE_WINDOW_H__ */ diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl index c6fc8848aa..eeef3df7b0 100644 --- a/arm_compute/core/Window.inl +++ b/arm_compute/core/Window.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -32,6 +32,13 @@ inline Window::Window(const Window &src) } } +inline Window &Window::operator=(const arm_compute::Window &rhs) +{ + Window tmp(rhs); + swap(*this, tmp); + return *this; +} + inline constexpr const Window::Dimension &Window::operator[](size_t dimension) const { // Precondition: dimension < Coordinates::num_max_dimensions @@ -267,4 +274,9 @@ inline size_t Window::num_iterations_total() const } return total; } + +inline void swap(Window &lhs, Window &rhs) +{ + lhs._dims.swap(rhs._dims); } +} // namespace arm_compute diff --git a/arm_compute/graph/GraphBuilder.h b/arm_compute/graph/GraphBuilder.h index bcf80f9c02..f1d387b719 100644 --- a/arm_compute/graph/GraphBuilder.h +++ b/arm_compute/graph/GraphBuilder.h @@ -217,7 +217,7 @@ public: * * @return Node ID of the created node, EmptyNodeID in case of error */ - static NodeID add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, DetectionOutputLayerInfo detect_info); + static NodeID add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, const DetectionOutputLayerInfo &detect_info); /** Adds a Dummy node to the graph * * @note this node if for debugging purposes. Just alters the shape of the graph pipeline as requested. @@ -353,7 +353,7 @@ public: * * @return Node ID of the created node, EmptyNodeID in case of error */ - static NodeID add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, PriorBoxLayerInfo prior_info); + static NodeID add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, const PriorBoxLayerInfo &prior_info); /** Adds a reorg layer node to the graph * * @param[in] g Graph to add the node to diff --git a/arm_compute/graph/frontend/Layers.h b/arm_compute/graph/frontend/Layers.h index 4e6f0eee2d..a4c03a68a0 100644 --- a/arm_compute/graph/frontend/Layers.h +++ b/arm_compute/graph/frontend/Layers.h @@ -478,7 +478,7 @@ public: * @param[in] sub_stream_prior PriorBox graph sub-stream. * @param[in] detect_info DetectionOutput parameters. */ - DetectionOutputLayer(SubStream &&sub_stream_conf, SubStream &&sub_stream_prior, DetectionOutputLayerInfo detect_info) + DetectionOutputLayer(SubStream &&sub_stream_conf, SubStream &&sub_stream_prior, const DetectionOutputLayerInfo &detect_info) : _ss_conf(std::move(sub_stream_conf)), _ss_prior(std::move(sub_stream_prior)), _detect_info(detect_info) { } @@ -838,7 +838,7 @@ public: * @param[in] sub_stream First graph sub-stream * @param[in] prior_info PriorBox parameters. */ - PriorBoxLayer(SubStream &&sub_stream, PriorBoxLayerInfo prior_info) + PriorBoxLayer(SubStream &&sub_stream, const PriorBoxLayerInfo &prior_info) : _ss(std::move(sub_stream)), _prior_info(prior_info) { } diff --git a/examples/graph_mobilenet.cpp b/examples/graph_mobilenet.cpp index 10bb890372..a3c77fea26 100644 --- a/examples/graph_mobilenet.cpp +++ b/examples/graph_mobilenet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -78,7 +78,7 @@ public: // Set graph hints graph << common_params.target - << DepthwiseConvolutionMethod::Optimized3x3 // FIXME(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method + << DepthwiseConvolutionMethod::Optimized3x3 // TODO(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method << common_params.fast_math_hint; // Create core graph diff --git a/examples/graph_mobilenet_v2.cpp b/examples/graph_mobilenet_v2.cpp index 9b1cb8caa0..9138e540a8 100644 --- a/examples/graph_mobilenet_v2.cpp +++ b/examples/graph_mobilenet_v2.cpp @@ -70,7 +70,7 @@ public: // Set graph hints graph << common_params.target - << DepthwiseConvolutionMethod::Optimized3x3 // FIXME(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method + << DepthwiseConvolutionMethod::Optimized3x3 // TODO(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method << common_params.fast_math_hint; // Create core graph diff --git a/examples/graph_ssd_mobilenet.cpp b/examples/graph_ssd_mobilenet.cpp index 780ee38670..92abd6a213 100644 --- a/examples/graph_ssd_mobilenet.cpp +++ b/examples/graph_ssd_mobilenet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -72,7 +72,7 @@ public: // Set graph hints graph << common_params.target - << DepthwiseConvolutionMethod::Optimized3x3 // FIXME(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method + << DepthwiseConvolutionMethod::Optimized3x3 // TODO(COMPMID-1073): Add heuristics to automatically call the optimized 3x3 method << common_params.fast_math_hint; // Create core graph diff --git a/src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp b/src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp index 471b3209ac..12affa9880 100644 --- a/src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp +++ b/src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -284,7 +284,7 @@ std::pair validate_and_configure_window(ITensorInfo *input, ITen TensorShape output_shape = misc::shape_calculator::compute_deep_convolution_shape(*input, *weights, conv_info); // Output auto inizialitation if not yet initialized - // FIXME: input->clone()->set_tensor_shape(output_shape) doesn't work with subtensors for grouped direct convolutions (AlexNet). + // TODO(COMPMID-2078): input->clone()->set_tensor_shape(output_shape) doesn't work with subtensors for grouped direct convolutions (AlexNet). auto_init_if_empty(*output, output_shape, 1, input->data_type(), @@ -363,7 +363,7 @@ void CLDirectConvolutionLayerKernel::configure(const ICLTensor *input, const ICL TensorShape output_shape = misc::shape_calculator::compute_deep_convolution_shape(*input->info(), *weights->info(), conv_info); // Output auto inizialitation if not yet initialized - // FIXME: input->clone()->set_tensor_shape(output_shape) doesn't work with subtensors for grouped direct convolutions (AlexNet). + // TODO(COMPMID-2078): input->clone()->set_tensor_shape(output_shape) doesn't work with subtensors for grouped direct convolutions (AlexNet). auto_init_if_empty(*output->info(), output_shape, 1, diff --git a/src/graph/GraphBuilder.cpp b/src/graph/GraphBuilder.cpp index 3f40aeadcb..b96a242acf 100644 --- a/src/graph/GraphBuilder.cpp +++ b/src/graph/GraphBuilder.cpp @@ -369,7 +369,7 @@ NodeID GraphBuilder::add_depthwise_convolution_node(Graph &g, NodeParams params, return conv_nid; } -NodeID GraphBuilder::add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, DetectionOutputLayerInfo detect_info) +NodeID GraphBuilder::add_detection_output_node(Graph &g, NodeParams params, NodeIdxPair input_loc, NodeIdxPair input_conf, NodeIdxPair input_priorbox, const DetectionOutputLayerInfo &detect_info) { CHECK_NODEIDX_PAIR(input_loc, g); CHECK_NODEIDX_PAIR(input_conf, g); @@ -544,7 +544,7 @@ NodeID GraphBuilder::add_pooling_node(Graph &g, NodeParams params, NodeIdxPair i return create_simple_single_input_output_node(g, params, input, pool_info); } -NodeID GraphBuilder::add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, PriorBoxLayerInfo prior_info) +NodeID GraphBuilder::add_priorbox_node(Graph &g, NodeParams params, NodeIdxPair input0, NodeIdxPair input1, const PriorBoxLayerInfo &prior_info) { CHECK_NODEIDX_PAIR(input0, g); CHECK_NODEIDX_PAIR(input1, g); diff --git a/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp b/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp index 7105e85061..8f7a62157f 100644 --- a/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLGEMMConvolutionLayer.cpp @@ -262,7 +262,7 @@ void CLGEMMConvolutionLayer::configure(const ICLTensor *input, const ICLTensor * shape_gemm.set(0, mat_weights_cols); shape_gemm.set(1, conv_w * conv_h); - // FIXME: input->clone() doesn't work with subtensors for grouped convolutions. + // TODO(COMPMID-2078): input->clone() doesn't work with subtensors for grouped convolutions. TensorInfo info_gemm(shape_gemm, 1, data_type); info_gemm.set_quantization_info(output->info()->quantization_info()).set_data_layout(input->info()->data_layout()); _gemm_output.allocator()->init(info_gemm); diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h index 47656766a6..4ae484f430 100644 --- a/utils/GraphUtils.h +++ b/utils/GraphUtils.h @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_GRAPH_UTILS_H__ -#define __ARM_COMPUTE_GRAPH_UTILS_H__ +#ifndef __ARM_COMPUTE_UTILS_GRAPH_UTILS_H__ +#define __ARM_COMPUTE_UTILS_GRAPH_UTILS_H__ #include "arm_compute/core/PixelValue.h" #include "arm_compute/core/Utils.h" @@ -601,4 +601,4 @@ inline graph::Target set_target_hint(int target) } // namespace graph_utils } // namespace arm_compute -#endif /* __ARM_COMPUTE_GRAPH_UTILS_H__ */ +#endif /* __ARM_COMPUTE_UTILS_GRAPH_UTILS_H__ */ diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index 7c23399bc1..70196882de 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -978,7 +978,6 @@ inline std::string to_string(const TensorInfo &info) return str.str(); } -//FIXME: Check why this doesn't work and the TensorShape and Coordinates overload are needed /** Formatted output of the Dimensions type. * * @param[in] dimensions Type to output. diff --git a/utils/command_line/CommandLineParser.h b/utils/command_line/CommandLineParser.h index 06c4bf5e2f..f834af8e9f 100644 --- a/utils/command_line/CommandLineParser.h +++ b/utils/command_line/CommandLineParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -225,7 +225,7 @@ inline void CommandLineParser::print_help(const std::string &program_name) const for(const auto &option : _positional_options) { - //FIXME: Print help string as well + // TODO(COMPMID-2079): Print help string as well std::cout << option->name() << "\n"; } } -- cgit v1.2.1