aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-11-23 11:44:58 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-11-28 11:56:01 +0000
commit7900a9efa421f0ac8faf9bb939f5c536b42c62b0 (patch)
tree5f336a5be6463025ed5f88b3752aaf28d7fe46a4 /arm_compute/core
parent3175fcf63249673f33fd1638879adad4baab545b (diff)
downloadComputeLibrary-7900a9efa421f0ac8faf9bb939f5c536b42c62b0.tar.gz
COMPMID-1716: CL Comparison operations
Adds support for Equal,NotEqual,Less,LessEqual,Greater,GreaterEqual Change-Id: If0cdf4aae7f95c94709b195eee485f6663f45909
Diffstat (limited to 'arm_compute/core')
-rw-r--r--arm_compute/core/CL/CLKernels.h1
-rw-r--r--arm_compute/core/CL/kernels/CLComparisonKernel.h80
-rw-r--r--arm_compute/core/Types.h27
-rw-r--r--arm_compute/core/Utils.h2
4 files changed, 101 insertions, 9 deletions
diff --git a/arm_compute/core/CL/CLKernels.h b/arm_compute/core/CL/CLKernels.h
index a045322353..c7c12975e0 100644
--- a/arm_compute/core/CL/CLKernels.h
+++ b/arm_compute/core/CL/CLKernels.h
@@ -45,6 +45,7 @@
#include "arm_compute/core/CL/kernels/CLChannelShuffleLayerKernel.h"
#include "arm_compute/core/CL/kernels/CLCol2ImKernel.h"
#include "arm_compute/core/CL/kernels/CLColorConvertKernel.h"
+#include "arm_compute/core/CL/kernels/CLComparisonKernel.h"
#include "arm_compute/core/CL/kernels/CLConvertFullyConnectedWeightsKernel.h"
#include "arm_compute/core/CL/kernels/CLConvolutionKernel.h"
#include "arm_compute/core/CL/kernels/CLCopyKernel.h"
diff --git a/arm_compute/core/CL/kernels/CLComparisonKernel.h b/arm_compute/core/CL/kernels/CLComparisonKernel.h
new file mode 100644
index 0000000000..d21bffa521
--- /dev/null
+++ b/arm_compute/core/CL/kernels/CLComparisonKernel.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLCOMPARISONKERNEL_H__
+#define __ARM_COMPUTE_CLCOMPARISONKERNEL_H__
+
+#include "arm_compute/core/CL/ICLKernel.h"
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+// Forward declarations
+class ICLTensor;
+
+/** Interface for the comparison kernel. */
+class CLComparisonKernel : public ICLKernel
+{
+public:
+ /** Default constructor. */
+ CLComparisonKernel();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLComparisonKernel(const CLComparisonKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLComparisonKernel &operator=(const CLComparisonKernel &) = delete;
+ /** Allow instances of this class to be moved */
+ CLComparisonKernel(CLComparisonKernel &&) = default;
+ /** Allow instances of this class to be moved */
+ CLComparisonKernel &operator=(CLComparisonKernel &&) = default;
+ /** Default destructor */
+ ~CLComparisonKernel() = default;
+ /** Set the inputs and output tensors
+ *
+ * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
+ * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
+ * @param[out] output Destination tensor. Data types supported: U8.
+ * @param[in] operation Comparison operation to use.
+ */
+ void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ComparisonOperation operation);
+ /** Static function to check if given info will lead to a valid configuration of @ref CLComparisonKernel
+ *
+ * @param[in] input1 Source tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
+ * @param[in] input2 Source tensor. Data types supported: Same as @p input1.
+ * @param[in] output Destination tensor. Data types supported: U8.
+ * @param[in] operation Comparison operation to use.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation);
+
+ // Inherited methods overridden:
+ void run(const Window &window, cl::CommandQueue &queue) override;
+ BorderSize border_size() const override;
+
+private:
+ const ICLTensor *_input1; /**< Source tensor 1 */
+ const ICLTensor *_input2; /**< Source tensor 2 */
+ ICLTensor *_output; /**< Destination tensor */
+};
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_CLCOMPARISONKERNEL_H__ */
diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h
index d6122a683f..5ddd207100 100644
--- a/arm_compute/core/Types.h
+++ b/arm_compute/core/Types.h
@@ -125,6 +125,25 @@ enum class DataLayoutDimension
BATCHES /**< batches */
};
+/** Available ConvolutionMethod*/
+enum class ConvolutionMethod
+{
+ GEMM, /**< Convolution using GEMM */
+ DIRECT, /**< Direct convolution */
+ WINOGRAD /**< Convolution using Winograd */
+};
+
+/** Supported comparison operations */
+enum class ComparisonOperation
+{
+ Equal, /**< Equal comparison ( \f$ x == y \f$ ) */
+ NotEqual, /**< NotEqual comparison ( \f$ x != y \f$ ) */
+ Greater, /**< Greater comparison ( \f$ x > y \f$ ) */
+ GreaterEqual, /**< Greater equal comparison ( \f$ x >= y \f$ ) */
+ Less, /**< Less comparison ( \f$ x < y \f$ ) */
+ LessEqual /**< Less equal comparison ( \f$ x <= y \f$ ) */
+};
+
/** Quantization settings (used for QASYMM8 data type) */
struct QuantizationInfo
{
@@ -1795,13 +1814,5 @@ struct IOFormatInfo
/** Align columns */
bool align_columns;
};
-
-/** Available ConvolutionMethod*/
-enum class ConvolutionMethod
-{
- GEMM, /**< Convolution using GEMM */
- DIRECT, /**< Direct convolution */
- WINOGRAD /**< Convolution using Winograd */
-};
} // namespace arm_compute
#endif /* __ARM_COMPUTE_TYPES_H__ */
diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h
index e7fbbfee65..f1395a40d9 100644
--- a/arm_compute/core/Utils.h
+++ b/arm_compute/core/Utils.h
@@ -1013,7 +1013,7 @@ inline bool is_data_type_quantized_asymmetric(DataType dt)
inline std::string float_to_string_with_full_precision(float val)
{
std::stringstream ss;
- ss.precision(std::numeric_limits<float>::digits10 + 1);
+ ss.precision(std::numeric_limits<float>::max_digits10);
ss << val;
if(val != static_cast<int>(val))