COMPMID-3274: Add support for QASYMM8_SIGNED in CPPBoxWithNonMaximaSuppressionLimit
authorSheri Zhang <sheri.zhang@arm.com>
Mon, 16 Mar 2020 21:25:52 +0000 (21:25 +0000)
committerSheri Zhang <sheri.zhang@arm.com>
Mon, 23 Mar 2020 11:23:18 +0000 (11:23 +0000)
Signed-off-by: Sheri Zhang <sheri.zhang@arm.com>
Change-Id: I2b95dbf97eb852d9cd72710d79a40de82ea37595
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2894
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>

arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h
src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp

index 171f5e63b622b09f5f7c8b150ae540c89b1a2403..b6f55b5bf81f025ad2edafa1fd9a8e2e12808557 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 ARM Limited.
+ * Copyright (c) 2018-2020 ARM Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -47,14 +47,14 @@ public:
     CPPBoxWithNonMaximaSuppressionLimit &operator=(const CPPBoxWithNonMaximaSuppressionLimit &) = delete;
     /** Configure the BoxWithNonMaximaSuppressionLimit CPP kernel
      *
-     * @param[in]  scores_in        The scores input tensor of size [count, num_classes]. Data types supported: QASYMM8/F16/F32
+     * @param[in]  scores_in        The scores input tensor of size [count, num_classes]. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32
      * @param[in]  boxes_in         The boxes input tensor of size [count, num_classes * 4].
-     *                              Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8, otherwise same as @p scores_in
+     *                              Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8/QASYMM8_SIGNED, otherwise same as @p scores_in
      * @param[in]  batch_splits_in  The batch splits input tensor of size [batch_size]. Data types supported: Same as @p scores_in
      *                              @note Can be a nullptr. If not a nullptr, @p scores_in and @p boxes_in have items from multiple images.
      * @param[out] scores_out       The scores output tensor of size [N]. Data types supported: Same as @p scores_in
      * @param[out] boxes_out        The boxes output tensor of size [N, 4].
-     *                              Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8, otherwise same as @p scores_in
+     *                              Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8/QASYMM8_SIGNED, otherwise same as @p scores_in
      * @param[out] classes          The classes output tensor of size [N]. Data types supported: Same as @p scores_in
      * @param[out] batch_splits_out (Optional) The batch splits output tensor. Data types supported: Same as @p scores_in
      * @param[out] keeps            (Optional) The keeps output tensor of size [N]. Data types supported: Same as @p scores_in
@@ -65,14 +65,14 @@ public:
                    ITensor *batch_splits_out = nullptr, ITensor *keeps = nullptr, ITensor *keeps_size = nullptr, const BoxNMSLimitInfo info = BoxNMSLimitInfo());
     /** Static function to check if given info will lead to a valid configuration of @ref CPPDetectionOutputLayer
      *
-     * @param[in] scores_in        The scores input tensor of size [count, num_classes]. Data types supported: QASYMM8/F16/F32
+     * @param[in] scores_in        The scores input tensor of size [count, num_classes]. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32
      * @param[in] boxes_in         The boxes input tensor of size [count, num_classes * 4].
-     *                             Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8, otherwise same as @p scores_in
+     *                             Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8/QASYMM8_SIGNED, otherwise same as @p scores_in
      * @param[in] batch_splits_in  The batch splits input tensor of size [batch_size]. Data types supported: Same as @p scores_in
      *                             @note Can be a nullptr. If not a nullptr, @p scores_in and @p boxes_in have items from multiple images.
      * @param[in] scores_out       The scores output tensor of size [N]. Data types supported: Same as @p scores_in
      * @param[in] boxes_out        The boxes output tensor of size [N, 4].
-     *                             Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8, otherwise same as @p scores_in
+     *                             Data types supported: QASYMM16 with 0.125 scale and 0 offset if @p scores_in is QASYMM8/QASYMM8_SIGNED, otherwise same as @p scores_in
      * @param[in] classes          The classes output tensor of size [N]. Data types supported: Same as @p scores_in
      * @param[in] batch_splits_out (Optional) The batch splits output tensor. Data types supported: Same as @p scores_in
      * @param[in] keeps            (Optional) The keeps output tensor of size [N]. Data types supported: Same as @p scores_in
index d4be939c52aef8f734599ddf6e25a4e11dabe5ad..232f71dbeae43282899cfde6df6fa712151c2521 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 ARM Limited.
+ * Copyright (c) 2018-2020 ARM Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -49,6 +49,13 @@ void dequantize_tensor(const ITensor *input, ITensor *output)
             },
             input_it, output_it);
             break;
+        case DataType::QASYMM8_SIGNED:
+            execute_window_loop(window, [&](const Coordinates &)
+            {
+                *reinterpret_cast<float *>(output_it.ptr()) = dequantize_qasymm8_signed(*reinterpret_cast<const int8_t *>(input_it.ptr()), qinfo);
+            },
+            input_it, output_it);
+            break;
         case DataType::QASYMM16:
             execute_window_loop(window, [&](const Coordinates &)
             {
@@ -80,6 +87,13 @@ void quantize_tensor(const ITensor *input, ITensor *output)
             },
             input_it, output_it);
             break;
+        case DataType::QASYMM8_SIGNED:
+            execute_window_loop(window, [&](const Coordinates &)
+            {
+                *reinterpret_cast<int8_t *>(output_it.ptr()) = quantize_qasymm8_signed(*reinterpret_cast<const float *>(input_it.ptr()), qinfo);
+            },
+            input_it, output_it);
+            break;
         case DataType::QASYMM16:
             execute_window_loop(window, [&](const Coordinates &)
             {
@@ -121,7 +135,7 @@ void CPPBoxWithNonMaximaSuppressionLimit::configure(const ITensor *scores_in, co
 {
     ARM_COMPUTE_ERROR_ON_NULLPTR(scores_in, boxes_in, scores_out, boxes_out, classes);
 
-    _is_qasymm8 = scores_in->info()->data_type() == DataType::QASYMM8;
+    _is_qasymm8 = scores_in->info()->data_type() == DataType::QASYMM8 || scores_in->info()->data_type() == DataType::QASYMM8_SIGNED;
 
     _scores_in        = scores_in;
     _boxes_in         = boxes_in;
@@ -198,9 +212,9 @@ Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const
 {
     ARM_COMPUTE_UNUSED(batch_splits_in, batch_splits_out, keeps, keeps_size, info);
     ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(scores_in, boxes_in, scores_out, boxes_out, classes);
-    ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(scores_in, 1, DataType::QASYMM8, DataType::F16, DataType::F32);
+    ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(scores_in, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::F16, DataType::F32);
 
-    const bool is_qasymm8 = scores_in->data_type() == DataType::QASYMM8;
+    const bool is_qasymm8 = scores_in->data_type() == DataType::QASYMM8 || scores_in->data_type() == DataType::QASYMM8_SIGNED;
     if(is_qasymm8)
     {
         ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(boxes_in, 1, DataType::QASYMM16);