From 053b915160b6cf8fb07d7914e9a10bc7cf716eb3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Shubham=20Gupta/SNAP=20/SRI-Bangalore/Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 14 Jan 2019 03:20:32 +0530 Subject: [PATCH] Correction in variable names in CL Arg op files (#4125) Since somewhere in code variable name is argminmax_axis and somewhere it is just axis along with comments having name as axis.So, this patch will corrects the comments and replaces all argminmax_axis to axis to have a uniformity in variable name for axis. Signed-off-by: shubham --- .../core/CL/kernels/CLArgMinMaxKernel.h | 22 ++++++------- .../arm_compute/runtime/CL/functions/CLArgMinMax.h | 26 ++++++--------- .../src/core/CL/cl_kernels/arg_operation.cl | 2 +- .../src/core/CL/kernels/CLArgMinMaxKernel.cpp | 37 +++++++++++----------- .../src/runtime/CL/functions/CLArgMinMax.cpp | 16 +++++----- 5 files changed, 47 insertions(+), 56 deletions(-) diff --git a/libs/ARMComputeEx/arm_compute/core/CL/kernels/CLArgMinMaxKernel.h b/libs/ARMComputeEx/arm_compute/core/CL/kernels/CLArgMinMaxKernel.h index ea4f5df..c896088 100644 --- a/libs/ARMComputeEx/arm_compute/core/CL/kernels/CLArgMinMaxKernel.h +++ b/libs/ARMComputeEx/arm_compute/core/CL/kernels/CLArgMinMaxKernel.h @@ -21,8 +21,8 @@ * @ingroup COM_AI_RUNTIME */ -#ifndef __ARM_COMPUTE_CLARG_MIN_MAX_KERNEL_H__ -#define __ARM_COMPUTE_CLARG_MIN_MAX_KERNEL_H__ +#ifndef __ARM_COMPUTE_CLARGMINMAXKERNEL_H__ +#define __ARM_COMPUTE_CLARGMINMAXKERNEL_H__ #include "arm_compute/core/CL/ICLKernel.h" #include "arm_compute/core/TypesEx.h" @@ -32,7 +32,7 @@ namespace arm_compute class ICLTensor; /** - * @brief Class to define interface for the argminmax max kernel. + * @brief Class to define interface for the argminmax kernel. */ class CLArgMinMaxKernel : public ICLKernel { @@ -67,21 +67,21 @@ public: * @brief Initialise the kernel's input, output and border mode. * @param[in] input An input tensor. Data types supported: U8/QASYMM8/S32/F32. * @param[out] output The output tensor, Data types supported: same as @p input. - * @param[in] argminmax_axis Axis to argminmax + * @param[in] axis Axis along which to reduce. It must be sorted and no duplicates. * return N/A */ - void configure(const ICLTensor *input, ICLTensor *output, const uint32_t argminmax_axis, - ArgOperation op); + void configure(const ICLTensor *input, ICLTensor *output, const uint32_t axis, ArgOperation op); /** * @brief Static function to check if given info will lead to a valid configuration of @ref * CLArgMinMaxKernel * @param[in] input An input tensor info. Data types supported: U8/QASYMM8/S32/F32. * @param[in] output The output tensor info, Data types supported: same as @p input1. - * @param[in] argminmax_axis Axis to argminmax + * @param[in] axis Axis along which to reduce. It must be sorted and no duplicates. + * Note: U8 requires both inputs to be U8. * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, - const uint32_t argminmax_axis, ArgOperation op); + static Status validate(const ITensorInfo *input, const ITensorInfo *output, const uint32_t axis, + ArgOperation op); /* * @brief Run CLArgMinMaxKernel op @@ -94,7 +94,7 @@ public: private: const ICLTensor *_input; ICLTensor *_output; - uint32_t _argminmax_axis; + uint32_t _axis; }; } // namespace arm_compute -#endif /*__ARM_COMPUTE_CLargminmaxMAXKERNEL_H__ */ +#endif /*__ARM_COMPUTE_CLARGMINMAXKERNEL_H__ */ diff --git a/libs/ARMComputeEx/arm_compute/runtime/CL/functions/CLArgMinMax.h b/libs/ARMComputeEx/arm_compute/runtime/CL/functions/CLArgMinMax.h index 8044c58..1f80d60 100644 --- a/libs/ARMComputeEx/arm_compute/runtime/CL/functions/CLArgMinMax.h +++ b/libs/ARMComputeEx/arm_compute/runtime/CL/functions/CLArgMinMax.h @@ -21,8 +21,8 @@ * @brief This file contains arm_compute::CLArgMinMax class */ -#ifndef __ARM_COMPUTE_CLARG_MIN_MAX_H__ -#define __ARM_COMPUTE_CLARG_MIN_MAX_H__ +#ifndef __ARM_COMPUTE_CLARGMINMAX_H__ +#define __ARM_COMPUTE_CLARGMINMAX_H__ #include "arm_compute/core/CL/kernels/CLArgMinMaxKernel.h" #include "arm_compute/runtime/CL/CLTensor.h" @@ -71,31 +71,23 @@ public: * @param[in] input Input tensor. Data types supported: U8/QASYMM8/S32/F32. * @param[out] output The result of argminmaxMax operation. Data types supported: same as @p * input. - * @param[in] axis Axis to argminmax. It must be sorted and no duplicates. - * @param[in] is_min True for ArgMin operation. - * @param[in] is_max Ture for ArgMax operation. + * @param[in] axis Axis along which to reduce. It must be sorted and no duplicates. * @return N/A */ - void configure(ICLTensor *input, ICLTensor *output, std::vector argminmax_axis, - ArgOperation op); + void configure(ICLTensor *input, ICLTensor *output, std::vector axis, ArgOperation op); /** * @brief Static function to check if given info will lead to a valid configuration * @param[in] input Input tensor. Data types supported: U8/QASYMM8/S32/F32. - * @param[in] axis Axis to argminmax + * @param[in] axis Axis along which to reduce. It must be sorted and no duplicates. * @param[out] output The result of argminmaxMax operation. Data types supported: same as @p * input. * @return a status */ - static Status validate(const ITensorInfo *input, const std::vector &argminmax_axis, + static Status validate(const ITensorInfo *input, const std::vector &axis, const ITensorInfo *output, ArgOperation op); - /** - * @brief Run the kernels contained in the function - * This operation works on CPU on GPU depending on the value of argminmax_MAX_RUN_ON_CPU macro - * in CLArgMinMax.cpp. - * If argminmax_MAX_RUN_ON_CPU == 1, CPU runs this operation. - * Otherwise GPU runs this operation. + * @brief Run the OpenCL kernel for this operation * @return N/A */ void run() override; @@ -103,7 +95,7 @@ public: private: ICLTensor *_input; ICLTensor *_output; - std::vector _argminmax_axis; + std::vector _axis; ArgOperation _arg_op; std::unique_ptr _interm_tensors{nullptr}; @@ -111,4 +103,4 @@ private: size_t _num_of_kernels; }; } -#endif /*__ARM_COMPUTE_CLargminmax_MAX_H__ */ +#endif /*__ARM_COMPUTE_CLARGMINMAX_H__ */ diff --git a/libs/ARMComputeEx/src/core/CL/cl_kernels/arg_operation.cl b/libs/ARMComputeEx/src/core/CL/cl_kernels/arg_operation.cl index 9a6921d..d785f5f 100644 --- a/libs/ARMComputeEx/src/core/CL/cl_kernels/arg_operation.cl +++ b/libs/ARMComputeEx/src/core/CL/cl_kernels/arg_operation.cl @@ -44,7 +44,7 @@ * @param[in] output_stride_w Stride of the source tensor in W dimension (in bytes) * @param[in] output_step_w output_stride_w * number of elements along W processed per workitem(in bytes) * @param[in] output_offset_first_element_in_bytes The offset of the first element in the destination image - * @param[in] axis Axis through which reduction occurs for max value index + * @param[in] axis Axis through which reduction occurs * @param[in] dim Dimension across the axis to be reduced. */ diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLArgMinMaxKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLArgMinMaxKernel.cpp index b408921..76d534b 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLArgMinMaxKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLArgMinMaxKernel.cpp @@ -24,11 +24,11 @@ using namespace arm_compute; namespace { -const TensorShape inferOutputShape(const TensorShape &input_shape, const uint32_t argminmax_axis) +const TensorShape inferOutputShape(const TensorShape &input_shape, const uint32_t axis) { TensorShape out_shape{input_shape}; - out_shape.set(argminmax_axis, 1); + out_shape.set(axis, 1); return out_shape; } @@ -38,8 +38,8 @@ namespace { constexpr unsigned int num_elems_processed_per_iteration = 16; -Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, - const uint32_t argminmax_axis, ArgOperation op) +Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const uint32_t axis, + ArgOperation op) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_NOT_IN(input, DataType::S32, DataType::F32, DataType::U8); ARM_COMPUTE_ERROR_ON_DATA_TYPE_NOT_IN(output, DataType::S32); @@ -51,32 +51,31 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->tensor_shape().total_size() == 0, "Inputs are not broadcast compatible"); - const TensorShape output_shape = inferOutputShape(input->tensor_shape(), argminmax_axis); + const TensorShape output_shape = inferOutputShape(input->tensor_shape(), axis); ARM_COMPUTE_RETURN_ERROR_ON_MSG(output_shape.total_size() != output->tensor_shape().total_size(), - "output shape's size does not match argminmax_axis"); + "output shape's size does not match axis"); const auto num_dimensions = input->tensor_shape().num_dimensions(); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(argminmax_axis >= num_dimensions, - "argminmax_axis must be less than (input's rank)."); + ARM_COMPUTE_RETURN_ERROR_ON_MSG(axis >= num_dimensions, "axis must be less than (input's rank)."); return Status{}; } } // namespace -CLArgMinMaxKernel::CLArgMinMaxKernel() : _input(nullptr), _output(nullptr), _argminmax_axis() {} +CLArgMinMaxKernel::CLArgMinMaxKernel() : _input(nullptr), _output(nullptr), _axis() {} -void CLArgMinMaxKernel::configure(const ICLTensor *input, ICLTensor *output, - const uint32_t argminmax_axis, ArgOperation op) +void CLArgMinMaxKernel::configure(const ICLTensor *input, ICLTensor *output, const uint32_t axis, + ArgOperation op) { ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), argminmax_axis, op)); + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op)); _input = input; _output = output; - _argminmax_axis = argminmax_axis; + _axis = axis; std::unique_ptr output_info = output->info()->clone(); - output_info->set_tensor_shape(inferOutputShape(input->info()->tensor_shape(), argminmax_axis)); + output_info->set_tensor_shape(inferOutputShape(input->info()->tensor_shape(), axis)); // Construct kernel name for argmax and argmin based on axis std::string kernel_name = "arg_op"; @@ -113,10 +112,10 @@ void CLArgMinMaxKernel::configure(const ICLTensor *input, ICLTensor *output, } Status CLArgMinMaxKernel::validate(const ITensorInfo *input, const ITensorInfo *output, - const uint32_t argminmax_axis, ArgOperation op) + const uint32_t axis, ArgOperation op) { ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, argminmax_axis, op)); + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op)); return Status{}; } @@ -130,8 +129,8 @@ void CLArgMinMaxKernel::run(const Window &window, cl::CommandQueue &queue) unsigned int idx = 2 * num_arguments_per_4D_tensor(); // Skip the input and output parameters - _kernel.setArg(idx++, _argminmax_axis); - _kernel.setArg(idx++, shape_in[_argminmax_axis]); + _kernel.setArg(idx++, _axis); + _kernel.setArg(idx++, shape_in[_axis]); Window slice_out = window.first_slice_window_4D().collapse(ICLKernel::window(), 2, 4); @@ -144,7 +143,7 @@ void CLArgMinMaxKernel::run(const Window &window, cl::CommandQueue &queue) // Copy output's shape in order to use for recovering at end of this method const TensorShape shape_out = _output->info()->tensor_shape(); - _output->info()->set_tensor_shape(inferOutputShape(shape_in, _argminmax_axis)); + _output->info()->set_tensor_shape(inferOutputShape(shape_in, _axis)); do { diff --git a/libs/ARMComputeEx/src/runtime/CL/functions/CLArgMinMax.cpp b/libs/ARMComputeEx/src/runtime/CL/functions/CLArgMinMax.cpp index 5a0be88..d0e3767 100644 --- a/libs/ARMComputeEx/src/runtime/CL/functions/CLArgMinMax.cpp +++ b/libs/ARMComputeEx/src/runtime/CL/functions/CLArgMinMax.cpp @@ -23,7 +23,7 @@ namespace arm_compute { CLArgMinMax::CLArgMinMax() - : _input(nullptr), _output(nullptr), _argminmax_axis(), _interm_tensors(), _argminmax_kernels(), + : _input(nullptr), _output(nullptr), _axis(), _interm_tensors(), _argminmax_kernels(), _num_of_kernels() { } @@ -34,7 +34,7 @@ void CLArgMinMax::configure(ICLTensor *input, ICLTensor *output, std::vectorinfo(), axis, output->info(), op)); _input = input; _output = output; - _argminmax_axis = axis; + _axis = axis; _arg_op = op; // NOTE The argminmax_axis must have no duplication. _num_of_kernels = axis.size(); @@ -47,7 +47,7 @@ void CLArgMinMax::configure(ICLTensor *input, ICLTensor *output, std::vectorinfo()->tensor_shape()}; for (size_t i = 0; i < num_of_interm_tensors; i++) { - shape.set(_argminmax_axis[i], 1); + shape.set(_axis[i], 1); _interm_tensors[i].allocator()->init( TensorInfo(shape, input->info()->num_channels(), input->info()->data_type())); _interm_tensors[i].allocator()->allocate(); @@ -65,14 +65,14 @@ void CLArgMinMax::configure(ICLTensor *input, ICLTensor *output, std::vector &argminmax_axis, +Status CLArgMinMax::validate(const ITensorInfo *input, const std::vector &axis, const ITensorInfo *output, ArgOperation op) { - const size_t num_of_kernels = argminmax_axis.size(); + const size_t num_of_kernels = axis.size(); const size_t num_of_interm_tensors = num_of_kernels - 1; // Create temporary tensor infos @@ -84,7 +84,7 @@ Status CLArgMinMax::validate(const ITensorInfo *input, const std::vectordata_type()); interm_tensors[i].set_tensor_shape(shape); interm_tensors[i].set_num_channels(input->num_channels()); @@ -103,7 +103,7 @@ Status CLArgMinMax::validate(const ITensorInfo *input, const std::vector