From f025a77e99224798cf4a28d7e17aef86d2f5792f Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 26 May 2020 11:11:32 +0100 Subject: COMPMID-3363, COMPMID-3364: Add align_corners support to nearest neighbor - Both NEON and CL's Scale Kernel now supports aligned corners with nearest neighbor interpolation - Unsupported combination (center sampling policy with aligned corners) now fails on validation - Test suites for CL and NEON are pruned by removing unsupported combination Change-Id: Ieea4f145a131593b89b471dcec2b09619136b17c Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3297 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- tests/validation/CL/Scale.cpp | 278 +++++++++++++++++++++++++------ tests/validation/NEON/Scale.cpp | 109 ++++++++---- tests/validation/fixtures/ScaleFixture.h | 8 +- tests/validation/reference/Scale.cpp | 8 +- 4 files changed, 311 insertions(+), 92 deletions(-) (limited to 'tests/validation') diff --git a/tests/validation/CL/Scale.cpp b/tests/validation/CL/Scale.cpp index 848656a8d1..d1c0d5ddf1 100644 --- a/tests/validation/CL/Scale.cpp +++ b/tests/validation/CL/Scale.cpp @@ -55,12 +55,16 @@ const auto ScaleDataTypes = framework::dataset::make("DataType", DataType::F32, }); -/** Align corners, this functionality is supported only by NEON */ -const auto AlignCorners = framework::dataset::make("AlignCorners", +/** Sampling policy data set */ +const auto SamplingPolicySet = combine(datasets::SamplingPolicies(), + framework::dataset::make("AlignCorners", { false })); + +/** Sampling policy data set for Aligned Corners which only allows TOP_LEFT poicy.*/ +const auto AlignCornersSamplingPolicySet = combine(framework::dataset::make("SamplingPolicy", { - false, - true, -}); + SamplingPolicy::TOP_LEFT, +}), +framework::dataset::make("AlignCorners", { true })); /** Tolerance */ constexpr AbsoluteTolerance tolerance_q8(1); @@ -173,13 +177,12 @@ using CLScaleFixture = ScaleValidationFixture; TEST_SUITE(Float) TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -188,13 +191,41 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode:: // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + AlignCornersSamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::F32)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::F32)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -205,13 +236,12 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode:: } TEST_SUITE_END() // FP32 TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -220,13 +250,41 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::A // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + AlignCornersSamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::F16)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::F16)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -240,13 +298,12 @@ TEST_SUITE_END() // Float TEST_SUITE(Integer) TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::U8)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -255,13 +312,42 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8)), +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), + framework::dataset::make("DataType", + DataType::U8)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + AlignCornersSamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -272,13 +358,12 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode } TEST_SUITE_END() // U8 TEST_SUITE(S16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::S16)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -287,13 +372,42 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::S16)), +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), + framework::dataset::make("DataType", + DataType::S16)), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + AlignCornersSamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::S16)), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -309,15 +423,14 @@ template using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture; TEST_SUITE(Quantized) TEST_SUITE(QASYMM8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + datasets::BorderModes()), + SamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -326,15 +439,46 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::Da // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + AlignCornersSamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::QASYMM8)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", + DataType::QASYMM8)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -345,14 +489,28 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture, framework::Da } TEST_SUITE_END() // QASYMM8 TEST_SUITE(QASYMM8_SIGNED) -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + datasets::BorderModes()), + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleQuantizedFixture, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), + framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -361,14 +519,28 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture, framework::Dat // Validate output validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), datasets::BorderModes()), - datasets::SamplingPolicies()), - AlignCorners)) + SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), + framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), + framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); diff --git a/tests/validation/NEON/Scale.cpp b/tests/validation/NEON/Scale.cpp index 9ab169b251..c1c17ee46c 100644 --- a/tests/validation/NEON/Scale.cpp +++ b/tests/validation/NEON/Scale.cpp @@ -169,26 +169,22 @@ const auto ScaleDataLayouts = framework::dataset::make("DataLayout", }); /** Sampling policy data set */ -const auto SamplingPolicySet = framework::dataset::make("SamplingPolicy", -{ - SamplingPolicy::TOP_LEFT, - SamplingPolicy::CENTER, -}); +const auto SamplingPolicySet = combine(datasets::SamplingPolicies(), + framework::dataset::make("AlignCorners", { false })); -/** Align corners */ -const auto AlignCorners = framework::dataset::make("AlignCorners", +/** Sampling policy data set for Aligned Corners which only allows TOP_LEFT poicy.*/ +const auto AlignCornersSamplingPolicySet = combine(framework::dataset::make("SamplingPolicy", { - false, - true, -}); + SamplingPolicy::TOP_LEFT, +}), +framework::dataset::make("AlignCorners", { true })); /** Generating dataset for non-quantized data tyeps with the given shapes */ -#define ASSEMBLE_DATASET(shape) \ - combine(combine(combine(combine(combine((shape), ScaleDataLayouts), \ - InterpolationPolicySet), \ - datasets::BorderModes()), \ - SamplingPolicySet), \ - AlignCorners) +#define ASSEMBLE_DATASET(shape, samping_policy_set) \ + combine(combine(combine(combine((shape), ScaleDataLayouts), \ + InterpolationPolicySet), \ + datasets::BorderModes()), \ + samping_policy_set) /** Quantization information data set */ const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo", @@ -197,14 +193,13 @@ const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo", }); /** Generating dataset for quantized data tyeps with the given shapes */ -#define ASSEMBLE_QUANTIZED_DATASET(shape) \ - combine(combine(combine(combine(combine(combine(shape, \ - QuantizationInfoSet), \ - ScaleDataLayouts), \ - InterpolationPolicySet), \ - datasets::BorderModes()), \ - SamplingPolicySet), \ - AlignCorners) +#define ASSEMBLE_QUANTIZED_DATASET(shape, sampling_policy_set) \ + combine(combine(combine(combine(combine(shape, \ + QuantizationInfoSet), \ + ScaleDataLayouts), \ + InterpolationPolicySet), \ + datasets::BorderModes()), \ + sampling_policy_set) /** Tolerance */ constexpr AbsoluteTolerance tolerance_u8(1); @@ -410,7 +405,16 @@ using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture())), framework::dataset::make("DataType", DataType::F32)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -423,7 +427,16 @@ TEST_SUITE_END() // FP32 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC TEST_SUITE(FP16) const auto f16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector())), framework::dataset::make("DataType", DataType::F16)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -439,7 +452,16 @@ TEST_SUITE_END() // Float TEST_SUITE(Integer) TEST_SUITE(U8) const auto u8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector())), framework::dataset::make("DataType", DataType::U8)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_u8); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -451,7 +473,16 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode TEST_SUITE_END() // U8 TEST_SUITE(S16) const auto s16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector())), framework::dataset::make("DataType", DataType::S16)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -466,7 +497,16 @@ TEST_SUITE_END() // Integer TEST_SUITE(Quantized) TEST_SUITE(QASYMM8) const auto qasymm8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector())), framework::dataset::make("DataType", DataType::QASYMM8)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_u8); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); @@ -478,7 +518,16 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture, framework::Da TEST_SUITE_END() // QASYMM8 TEST_SUITE(QASYMM8_SIGNED) const auto qasymm8_signed_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape)) +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, SamplingPolicySet)) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region, tolerance_u8); +} +FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, AlignCornersSamplingPolicySet)) { //Create valid region TensorInfo src_info(_shape, 1, _data_type); diff --git a/tests/validation/fixtures/ScaleFixture.h b/tests/validation/fixtures/ScaleFixture.h index cf3c5c818f..f7ede917a6 100644 --- a/tests/validation/fixtures/ScaleFixture.h +++ b/tests/validation/fixtures/ScaleFixture.h @@ -54,7 +54,7 @@ public: _sampling_policy = sampling_policy; _data_type = data_type; _quantization_info = quantization_info; - _align_corners = align_corners && _policy == InterpolationPolicy::BILINEAR && _sampling_policy == SamplingPolicy::TOP_LEFT; + _align_corners = align_corners; generate_scale(shape); @@ -75,8 +75,10 @@ protected: constexpr float max_width{ 8192.0f }; constexpr float max_height{ 6384.0f }; - const float min_width = _align_corners ? 2.f : 1.f; - const float min_height = _align_corners ? 2.f : 1.f; + const bool is_align_corners_used = _align_corners && arm_compute::is_align_corners_allowed(_sampling_policy); + + const float min_width = is_align_corners_used ? 2.f : 1.f; + const float min_height = is_align_corners_used ? 2.f : 1.f; std::mt19937 generator(library->seed()); std::uniform_real_distribution distribution_float(_min_scale, _max_scale); diff --git a/tests/validation/reference/Scale.cpp b/tests/validation/reference/Scale.cpp index 73fe21cbf1..06bc42004f 100644 --- a/tests/validation/reference/Scale.cpp +++ b/tests/validation/reference/Scale.cpp @@ -46,13 +46,9 @@ SimpleTensor scale_core(const SimpleTensor &in, float scale_x, float scale shape_scaled.set(1, (in.shape()[1] + round_value) * scale_y); SimpleTensor out(shape_scaled, in.data_type()); - const auto needs_align_corners = policy == InterpolationPolicy::BILINEAR - && sampling_policy == SamplingPolicy::TOP_LEFT - && align_corners; - // Compute the ratio between source width/height and destination width/height - const auto wr = arm_compute::calculate_resize_ratio(in.shape()[0], out.shape()[0], needs_align_corners); - const auto hr = arm_compute::calculate_resize_ratio(in.shape()[1], out.shape()[1], needs_align_corners); + const auto wr = arm_compute::calculate_resize_ratio(in.shape()[0], out.shape()[0], align_corners); + const auto hr = arm_compute::calculate_resize_ratio(in.shape()[1], out.shape()[1], align_corners); const auto width = static_cast(in.shape().x()); const auto height = static_cast(in.shape().y()); -- cgit v1.2.1