From d9a623a1729a9a613f7dcf8cf8536e5d8dd921b4 Mon Sep 17 00:00:00 2001 From: Sheri Zhang Date: Mon, 16 Mar 2020 21:25:52 +0000 Subject: COMPMID-3274: Add support for QASYMM8_SIGNED in CPPBoxWithNonMaximaSuppressionLimit Signed-off-by: Sheri Zhang Change-Id: I2b95dbf97eb852d9cd72710d79a40de82ea37595 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2894 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- .../CPPBoxWithNonMaximaSuppressionLimit.h | 14 +++++++------- .../CPPBoxWithNonMaximaSuppressionLimit.cpp | 22 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h b/arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h index 171f5e63b6..b6f55b5bf8 100644 --- a/arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h +++ b/arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h @@ -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 diff --git a/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp b/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp index d4be939c52..232f71dbea 100644 --- a/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp +++ b/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp @@ -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(output_it.ptr()) = dequantize_qasymm8_signed(*reinterpret_cast(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(output_it.ptr()) = quantize_qasymm8_signed(*reinterpret_cast(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); -- cgit v1.2.1