diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2019-08-23 11:49:04 +0100 |
---|---|---|
committer | Michele Di Giorgio <michele.digiorgio@arm.com> | 2019-08-29 09:17:46 +0000 |
commit | 578a9fc6c06ebbd6e2650372029e339a4cbcacca (patch) | |
tree | 7aa428d18323cce34dabe088063d2cf533c36fac /tests/validation | |
parent | c7ec194d5ae5ee5c9af3e6aa3de43e30382d8f87 (diff) | |
download | ComputeLibrary-578a9fc6c06ebbd6e2650372029e339a4cbcacca.tar.gz |
COMPMID-2317: Implement CLROIAlignLayer
Change-Id: Iaa61b7a3528d3f82339d2ff8a2d77e77a1c68603
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1821
Reviewed-by: Pablo Marquez <pablo.tello@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/CL/ROIAlignLayer.cpp | 70 | ||||
-rw-r--r-- | tests/validation/Helpers.cpp | 12 | ||||
-rw-r--r-- | tests/validation/Helpers.h | 10 | ||||
-rw-r--r-- | tests/validation/fixtures/ROIAlignLayerFixture.h | 93 | ||||
-rw-r--r-- | tests/validation/reference/ROIAlignLayer.cpp | 39 | ||||
-rw-r--r-- | tests/validation/reference/ROIAlignLayer.h | 6 |
6 files changed, 177 insertions, 53 deletions
diff --git a/tests/validation/CL/ROIAlignLayer.cpp b/tests/validation/CL/ROIAlignLayer.cpp index 566e1985b3..b213c6815f 100644 --- a/tests/validation/CL/ROIAlignLayer.cpp +++ b/tests/validation/CL/ROIAlignLayer.cpp @@ -41,11 +41,13 @@ namespace validation { namespace { -RelativeTolerance<float> relative_tolerance_f32(0.01f); -AbsoluteTolerance<float> absolute_tolerance_f32(0.001f); +constexpr RelativeTolerance<float> relative_tolerance_f32(0.01f); +constexpr AbsoluteTolerance<float> absolute_tolerance_f32(0.001f); -RelativeTolerance<float> relative_tolerance_f16(0.01f); -AbsoluteTolerance<float> absolute_tolerance_f16(0.001f); +constexpr RelativeTolerance<float> relative_tolerance_f16(0.01f); +constexpr AbsoluteTolerance<float> absolute_tolerance_f16(0.001f); + +constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); } // namespace TEST_SUITE(CL) @@ -55,13 +57,14 @@ TEST_SUITE(RoiAlign) // clang-format off DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( framework::dataset::make("InputInfo", { TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), - TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/rois - TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/output - TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching depth size input/output - TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching number of rois and output batch size - TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Invalid number of values per ROIS - TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching height and width input/output - + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/rois + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/output + TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching depth size input/output + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching number of rois and output batch size + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Invalid number of values per ROIS + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching height and width input/output + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::QASYMM8, QuantizationInfo(1.f / 255.f, 127)), // Invalid ROIS data type + TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::QASYMM8, QuantizationInfo(1.f / 255.f, 127)), // Invalid ROIS Quantization Info }), framework::dataset::make("RoisInfo", { TensorInfo(TensorShape(5, 4U), 1, DataType::F32), TensorInfo(TensorShape(5, 4U), 1, DataType::F16), @@ -70,6 +73,8 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( TensorInfo(TensorShape(5, 10U), 1, DataType::F32), TensorInfo(TensorShape(4, 4U), 1, DataType::F32), TensorInfo(TensorShape(5, 4U), 1, DataType::F32), + TensorInfo(TensorShape(5, 4U), 1, DataType::F32), + TensorInfo(TensorShape(5, 4U), 1, DataType::QASYMM16, QuantizationInfo(0.2f, 0)), })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32), TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32), @@ -78,6 +83,8 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32), TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32), TensorInfo(TensorShape(5U, 5U, 3U, 4U), 1, DataType::F32), + TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::QASYMM8, QuantizationInfo(1.f / 255.f, 120)), + TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::QASYMM8, QuantizationInfo(1.f / 255.f, 120)), })), framework::dataset::make("PoolInfo", { ROIPoolingLayerInfo(7U, 7U, 1./8), ROIPoolingLayerInfo(7U, 7U, 1./8), @@ -86,8 +93,9 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( ROIPoolingLayerInfo(7U, 7U, 1./8), ROIPoolingLayerInfo(7U, 7U, 1./8), ROIPoolingLayerInfo(7U, 7U, 1./8), + ROIPoolingLayerInfo(7U, 7U, 1./8), })), - framework::dataset::make("Expected", { true, false, false, false, false, false, false })), + framework::dataset::make("Expected", { true, false, false, false, false, false, false, false, false })), input_info, rois_info, output_info, pool_info, expected) { ARM_COMPUTE_EXPECT(bool(CLROIAlignLayer::validate(&input_info.clone()->set_is_resizable(true), &rois_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), pool_info)) == expected, framework::LogLevel::ERRORS); @@ -99,24 +107,46 @@ template <typename T> using CLROIAlignLayerFixture = ROIAlignLayerFixture<CLTensor, CLAccessor, CLROIAlignLayer, T>; TEST_SUITE(Float) -FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerFloat, CLROIAlignLayerFixture<float>, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(), - framework::dataset::make("DataType", { DataType::F32 })), - framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(Small, CLROIAlignLayerFixture<float>, framework::DatasetMode::ALL, + combine(combine(datasets::SmallROIDataset(), + framework::dataset::make("DataType", { DataType::F32 })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) { // Validate output validate(CLAccessor(_target), _reference, relative_tolerance_f32, .02f, absolute_tolerance_f32); } -FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerHalf, CLROIAlignLayerFixture<half>, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(), - framework::dataset::make("DataType", { DataType::F16 })), - framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +TEST_SUITE_END() // FP32 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(Small, CLROIAlignLayerFixture<half>, framework::DatasetMode::ALL, + combine(combine(datasets::SmallROIDataset(), + framework::dataset::make("DataType", { DataType::F16 })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) { // Validate output validate(CLAccessor(_target), _reference, relative_tolerance_f16, .02f, absolute_tolerance_f16); } +TEST_SUITE_END() // FP16 TEST_SUITE_END() // Float +template <typename T> +using CLROIAlignLayerQuantizedFixture = ROIAlignLayerQuantizedFixture<CLTensor, CLAccessor, CLROIAlignLayer, T>; + +TEST_SUITE(Quantized) +TEST_SUITE(QASYMM8) +FIXTURE_DATA_TEST_CASE(Small, CLROIAlignLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, + combine(combine(combine(combine(datasets::SmallROIDataset(), + framework::dataset::make("DataType", { DataType::QASYMM8 })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 127) })), + framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(2.f / 255.f, 120) }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qasymm8); +} +TEST_SUITE_END() // QASYMM8 +TEST_SUITE_END() // Quantized + TEST_SUITE_END() // RoiAlign TEST_SUITE_END() // CL } // namespace validation diff --git a/tests/validation/Helpers.cpp b/tests/validation/Helpers.cpp index 360859e487..a811cabf56 100644 --- a/tests/validation/Helpers.cpp +++ b/tests/validation/Helpers.cpp @@ -120,6 +120,18 @@ SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint8_t> &src) return dst; } +SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint16_t> &src) +{ + const UniformQuantizationInfo &quantization_info = src.quantization_info().uniform(); + SimpleTensor<float> dst{ src.shape(), DataType::F32, 1, QuantizationInfo(), src.data_layout() }; + + for(int i = 0; i < src.num_elements(); ++i) + { + dst[i] = dequantize_qasymm16(src[i], quantization_info); + } + return dst; +} + SimpleTensor<uint8_t> convert_to_asymmetric(const SimpleTensor<float> &src, const QuantizationInfo &quantization_info) { SimpleTensor<uint8_t> dst{ src.shape(), DataType::QASYMM8, 1, quantization_info }; diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index 44dd7a9b81..0d6515b5c5 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -177,7 +177,7 @@ void fill_lookuptable(T &&table) } } -/** Convert quantized simple tensor into float using tensor quantization information. +/** Convert 8-bit asymmetric quantized simple tensor into float using tensor quantization information. * * @param[in] src Quantized tensor. * @@ -185,6 +185,14 @@ void fill_lookuptable(T &&table) */ SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint8_t> &src); +/** Convert 16-bit asymmetric quantized simple tensor into float using tensor quantization information. + * + * @param[in] src Quantized tensor. + * + * @return Float tensor. + */ +SimpleTensor<float> convert_from_asymmetric(const SimpleTensor<uint16_t> &src); + /** Convert float simple tensor into quantized using specified quantization information. * * @param[in] src Float tensor. diff --git a/tests/validation/fixtures/ROIAlignLayerFixture.h b/tests/validation/fixtures/ROIAlignLayerFixture.h index dfbb478a41..b9b85d3073 100644 --- a/tests/validation/fixtures/ROIAlignLayerFixture.h +++ b/tests/validation/fixtures/ROIAlignLayerFixture.h @@ -26,7 +26,7 @@ #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLROIAlignLayer.h" +#include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" @@ -42,14 +42,17 @@ namespace test namespace validation { template <typename TensorType, typename AccessorType, typename FunctionType, typename T> -class ROIAlignLayerFixture : public framework::Fixture +class ROIAlignLayerGenericFixture : public framework::Fixture { public: + using TRois = typename std::conditional<std::is_same<typename std::decay<T>::type, uint8_t>::value, uint16_t, T>::type; + template <typename...> - void setup(TensorShape input_shape, const ROIPoolingLayerInfo pool_info, TensorShape rois_shape, DataType data_type, DataLayout data_layout) + void setup(TensorShape input_shape, const ROIPoolingLayerInfo pool_info, TensorShape rois_shape, DataType data_type, DataLayout data_layout, QuantizationInfo qinfo, QuantizationInfo output_qinfo) { - _target = compute_target(input_shape, data_type, data_layout, pool_info, rois_shape); - _reference = compute_reference(input_shape, data_type, pool_info, rois_shape); + _rois_data_type = is_data_type_quantized_asymmetric(data_type) ? DataType::QASYMM16 : data_type; + _target = compute_target(input_shape, data_type, data_layout, pool_info, rois_shape, qinfo, output_qinfo); + _reference = compute_reference(input_shape, data_type, pool_info, rois_shape, qinfo, output_qinfo); } protected: @@ -66,17 +69,17 @@ protected: const size_t num_rois = rois_shape.y(); std::mt19937 gen(library->seed()); - T *rois_ptr = static_cast<T *>(rois.data()); + TRois *rois_ptr = static_cast<TRois *>(rois.data()); const float pool_width = pool_info.pooled_width(); const float pool_height = pool_info.pooled_height(); const float roi_scale = pool_info.spatial_scale(); // Calculate distribution bounds - const auto scaled_width = static_cast<T>((shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH)] / roi_scale) / pool_width); - const auto scaled_height = static_cast<T>((shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT)] / roi_scale) / pool_height); - const auto min_width = static_cast<T>(pool_width / roi_scale); - const auto min_height = static_cast<T>(pool_height / roi_scale); + const auto scaled_width = static_cast<float>((shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH)] / roi_scale) / pool_width); + const auto scaled_height = static_cast<float>((shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT)] / roi_scale) / pool_height); + const auto min_width = static_cast<float>(pool_width / roi_scale); + const auto min_height = static_cast<float>(pool_height / roi_scale); // Create distributions std::uniform_int_distribution<int> dist_batch(0, shape[3] - 1); @@ -93,11 +96,21 @@ protected: const auto x2 = x1 + dist_w(gen); const auto y2 = y1 + dist_h(gen); - rois_ptr[values_per_roi * pw] = batch_idx; - rois_ptr[values_per_roi * pw + 1] = x1; - rois_ptr[values_per_roi * pw + 2] = y1; - rois_ptr[values_per_roi * pw + 3] = x2; - rois_ptr[values_per_roi * pw + 4] = y2; + rois_ptr[values_per_roi * pw] = batch_idx; + if(rois.data_type() == DataType::QASYMM16) + { + rois_ptr[values_per_roi * pw + 1] = quantize_qasymm16(static_cast<float>(x1), rois.quantization_info()); + rois_ptr[values_per_roi * pw + 2] = quantize_qasymm16(static_cast<float>(y1), rois.quantization_info()); + rois_ptr[values_per_roi * pw + 3] = quantize_qasymm16(static_cast<float>(x2), rois.quantization_info()); + rois_ptr[values_per_roi * pw + 4] = quantize_qasymm16(static_cast<float>(y2), rois.quantization_info()); + } + else + { + rois_ptr[values_per_roi * pw + 1] = static_cast<TRois>(x1); + rois_ptr[values_per_roi * pw + 2] = static_cast<TRois>(y1); + rois_ptr[values_per_roi * pw + 3] = static_cast<TRois>(x2); + rois_ptr[values_per_roi * pw + 4] = static_cast<TRois>(y2); + } } } @@ -105,17 +118,23 @@ protected: DataType data_type, DataLayout data_layout, const ROIPoolingLayerInfo &pool_info, - const TensorShape rois_shape) + const TensorShape rois_shape, + const QuantizationInfo &qinfo, + const QuantizationInfo &output_qinfo) { if(data_layout == DataLayout::NHWC) { permute(input_shape, PermutationVector(2U, 0U, 1U)); } + const QuantizationInfo rois_qinfo = is_data_type_quantized(data_type) ? QuantizationInfo(0.125f, 0) : QuantizationInfo(); + // Create tensors - TensorType src = create_tensor<TensorType>(input_shape, data_type, 1, QuantizationInfo(), data_layout); - TensorType rois_tensor = create_tensor<TensorType>(rois_shape, data_type); - TensorType dst; + TensorType src = create_tensor<TensorType>(input_shape, data_type, 1, qinfo, data_layout); + TensorType rois_tensor = create_tensor<TensorType>(rois_shape, _rois_data_type, 1, rois_qinfo); + + const TensorShape dst_shape = misc::shape_calculator::compute_roi_align_shape(*(src.info()), *(rois_tensor.info()), pool_info); + TensorType dst = create_tensor<TensorType>(dst_shape, data_type, 1, output_qinfo, data_layout); // Create and configure function FunctionType roi_align_layer; @@ -147,23 +166,51 @@ protected: SimpleTensor<T> compute_reference(const TensorShape &input_shape, DataType data_type, const ROIPoolingLayerInfo &pool_info, - const TensorShape rois_shape) + const TensorShape rois_shape, + const QuantizationInfo &qinfo, + const QuantizationInfo &output_qinfo) { // Create reference tensor - SimpleTensor<T> src{ input_shape, data_type }; - SimpleTensor<T> rois_tensor{ rois_shape, data_type }; + SimpleTensor<T> src{ input_shape, data_type, 1, qinfo }; + const QuantizationInfo rois_qinfo = is_data_type_quantized(data_type) ? QuantizationInfo(0.125f, 0) : QuantizationInfo(); + SimpleTensor<TRois> rois_tensor{ rois_shape, _rois_data_type, 1, rois_qinfo }; // Fill reference tensor fill(src); generate_rois(rois_tensor, input_shape, pool_info, rois_shape); - return reference::roi_align_layer(src, rois_tensor, pool_info); + return reference::roi_align_layer(src, rois_tensor, pool_info, output_qinfo); } TensorType _target{}; SimpleTensor<T> _reference{}; + DataType _rois_data_type{}; +}; + +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class ROIAlignLayerFixture : public ROIAlignLayerGenericFixture<TensorType, AccessorType, FunctionType, T> +{ +public: + template <typename...> + void setup(TensorShape input_shape, const ROIPoolingLayerInfo pool_info, TensorShape rois_shape, DataType data_type, DataLayout data_layout) + { + ROIAlignLayerGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(input_shape, pool_info, rois_shape, data_type, data_layout, + QuantizationInfo(), QuantizationInfo()); + } }; +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class ROIAlignLayerQuantizedFixture : public ROIAlignLayerGenericFixture<TensorType, AccessorType, FunctionType, T> +{ +public: + template <typename...> + void setup(TensorShape input_shape, const ROIPoolingLayerInfo pool_info, TensorShape rois_shape, DataType data_type, + DataLayout data_layout, QuantizationInfo qinfo, QuantizationInfo output_qinfo) + { + ROIAlignLayerGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(input_shape, pool_info, rois_shape, + data_type, data_layout, qinfo, output_qinfo); + } +}; } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/reference/ROIAlignLayer.cpp b/tests/validation/reference/ROIAlignLayer.cpp index 8a76983d44..8ad78ff915 100644 --- a/tests/validation/reference/ROIAlignLayer.cpp +++ b/tests/validation/reference/ROIAlignLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -112,15 +112,31 @@ T clamp(T value, T lower, T upper) { return std::max(lower, std::min(value, upper)); } + +SimpleTensor<float> convert_rois_from_asymmetric(SimpleTensor<uint16_t> rois) +{ + const UniformQuantizationInfo &quantization_info = rois.quantization_info().uniform(); + SimpleTensor<float> dst{ rois.shape(), DataType::F32, 1, QuantizationInfo(), rois.data_layout() }; + + for(int i = 0; i < rois.num_elements(); i += 5) + { + dst[i] = static_cast<float>(rois[i]); // batch idx + dst[i + 1] = dequantize_qasymm16(rois[i + 1], quantization_info); + dst[i + 2] = dequantize_qasymm16(rois[i + 2], quantization_info); + dst[i + 3] = dequantize_qasymm16(rois[i + 3], quantization_info); + dst[i + 4] = dequantize_qasymm16(rois[i + 4], quantization_info); + } + return dst; +} } // namespace -template <typename T> -SimpleTensor<T> roi_align_layer(const SimpleTensor<T> &src, const SimpleTensor<T> &rois, const ROIPoolingLayerInfo &pool_info) +template <typename T, typename TRois> +SimpleTensor<T> roi_align_layer(const SimpleTensor<T> &src, const SimpleTensor<TRois> &rois, const ROIPoolingLayerInfo &pool_info, const QuantizationInfo &output_qinfo) { const size_t values_per_roi = rois.shape()[0]; const size_t num_rois = rois.shape()[1]; DataType dst_data_type = src.data_type(); - const auto *rois_ptr = static_cast<const T *>(rois.data()); + const auto *rois_ptr = static_cast<const TRois *>(rois.data()); TensorShape input_shape = src.shape(); TensorShape output_shape(pool_info.pooled_width(), pool_info.pooled_height(), src.shape()[2], num_rois); @@ -183,8 +199,19 @@ SimpleTensor<T> roi_align_layer(const SimpleTensor<T> &src, const SimpleTensor<T } return dst; } -template SimpleTensor<float> roi_align_layer(const SimpleTensor<float> &src, const SimpleTensor<float> &rois, const ROIPoolingLayerInfo &pool_info); -template SimpleTensor<half> roi_align_layer(const SimpleTensor<half> &src, const SimpleTensor<half> &rois, const ROIPoolingLayerInfo &pool_info); + +template SimpleTensor<float> roi_align_layer(const SimpleTensor<float> &src, const SimpleTensor<float> &rois, const ROIPoolingLayerInfo &pool_info, const QuantizationInfo &output_qinfo); +template SimpleTensor<half> roi_align_layer(const SimpleTensor<half> &src, const SimpleTensor<half> &rois, const ROIPoolingLayerInfo &pool_info, const QuantizationInfo &output_qinfo); + +template <> +SimpleTensor<uint8_t> roi_align_layer(const SimpleTensor<uint8_t> &src, const SimpleTensor<uint16_t> &rois, const ROIPoolingLayerInfo &pool_info, const QuantizationInfo &output_qinfo) +{ + SimpleTensor<float> src_tmp = convert_from_asymmetric(src); + SimpleTensor<float> rois_tmp = convert_rois_from_asymmetric(rois); + SimpleTensor<float> dst_tmp = roi_align_layer<float, float>(src_tmp, rois_tmp, pool_info, output_qinfo); + SimpleTensor<uint8_t> dst = convert_to_asymmetric(dst_tmp, output_qinfo); + return dst; +} } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/reference/ROIAlignLayer.h b/tests/validation/reference/ROIAlignLayer.h index b67ff42166..e1568133e7 100644 --- a/tests/validation/reference/ROIAlignLayer.h +++ b/tests/validation/reference/ROIAlignLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -36,8 +36,8 @@ namespace validation { namespace reference { -template <typename T> -SimpleTensor<T> roi_align_layer(const SimpleTensor<T> &src, const SimpleTensor<T> &rois, const ROIPoolingLayerInfo &pool_info); +template <typename T, typename TRois> +SimpleTensor<T> roi_align_layer(const SimpleTensor<T> &src, const SimpleTensor<TRois> &rois, const ROIPoolingLayerInfo &pool_info, const QuantizationInfo &output_qinfo); } // namespace reference } // namespace validation } // namespace test |