aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm_compute/core/Helpers.h15
-rw-r--r--arm_compute/core/Helpers.inl33
-rw-r--r--src/core/CL/kernels/CLScaleKernel.cpp2
-rw-r--r--src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp3
-rw-r--r--src/core/Helpers.cpp72
-rw-r--r--src/core/NEON/kernels/NEScaleKernel.cpp6
-rw-r--r--tests/validation/CL/Scale.cpp28
-rw-r--r--tests/validation/GLES_COMPUTE/Scale.cpp6
-rw-r--r--tests/validation/NEON/Scale.cpp14
-rw-r--r--tests/validation/fixtures/ScaleFixture.h13
10 files changed, 123 insertions, 69 deletions
diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h
index 6f3aba7077..4acb176250 100644
--- a/arm_compute/core/Helpers.h
+++ b/arm_compute/core/Helpers.h
@@ -622,15 +622,16 @@ bool set_quantization_info_if_empty(ITensorInfo &info, QuantizationInfo quantiza
/** Helper function to calculate the Valid Region for Scale.
*
- * @param[in] src_info Input tensor info used to check.
- * @param[in] dst_shape Shape of the output.
- * @param[in] policy Interpolation policy.
- * @param[in] border_size Size of the border.
- * @param[in] border_undefined True if the border is undefined.
+ * @param[in] src_info Input tensor info used to check.
+ * @param[in] dst_shape Shape of the output.
+ * @param[in] interpolate_policy Interpolation policy.
+ * @param[in] sampling_policy Sampling policy.
+ * @param[in] border_undefined True if the border is undefined.
*
- * @return The corrispondent valid region
+ * @return The corresponding valid region
*/
-ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy policy, BorderSize border_size, bool border_undefined);
+ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape,
+ InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined);
/** Convert a linear index into n-dimensional coordinates.
*
diff --git a/arm_compute/core/Helpers.inl b/arm_compute/core/Helpers.inl
index 3db8369f08..b359811328 100644
--- a/arm_compute/core/Helpers.inl
+++ b/arm_compute/core/Helpers.inl
@@ -300,39 +300,6 @@ inline bool set_quantization_info_if_empty(ITensorInfo &info, QuantizationInfo q
return false;
}
-inline ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy policy, BorderSize border_size, bool border_undefined)
-{
- const auto wr = static_cast<float>(dst_shape[0]) / static_cast<float>(src_info.tensor_shape()[0]);
- const auto hr = static_cast<float>(dst_shape[1]) / static_cast<float>(src_info.tensor_shape()[1]);
-
- ValidRegion valid_region{ Coordinates(), dst_shape, src_info.tensor_shape().num_dimensions() };
-
- Coordinates &anchor = valid_region.anchor;
- TensorShape &shape = valid_region.shape;
-
- anchor.set(0, (policy == InterpolationPolicy::BILINEAR
- && border_undefined) ?
- ((static_cast<int>(src_info.valid_region().anchor[0]) + border_size.left + 0.5f) * wr - 0.5f) :
- ((static_cast<int>(src_info.valid_region().anchor[0]) + 0.5f) * wr - 0.5f));
- anchor.set(1, (policy == InterpolationPolicy::BILINEAR
- && border_undefined) ?
- ((static_cast<int>(src_info.valid_region().anchor[1]) + border_size.top + 0.5f) * hr - 0.5f) :
- ((static_cast<int>(src_info.valid_region().anchor[1]) + 0.5f) * hr - 0.5f));
- float shape_out_x = (policy == InterpolationPolicy::BILINEAR
- && border_undefined) ?
- ((static_cast<int>(src_info.valid_region().anchor[0]) + static_cast<int>(src_info.valid_region().shape[0]) - 1) - 1 + 0.5f) * wr - 0.5f :
- ((static_cast<int>(src_info.valid_region().anchor[0]) + static_cast<int>(src_info.valid_region().shape[0])) + 0.5f) * wr - 0.5f;
- float shape_out_y = (policy == InterpolationPolicy::BILINEAR
- && border_undefined) ?
- ((static_cast<int>(src_info.valid_region().anchor[1]) + static_cast<int>(src_info.valid_region().shape[1]) - 1) - 1 + 0.5f) * hr - 0.5f :
- ((static_cast<int>(src_info.valid_region().anchor[1]) + static_cast<int>(src_info.valid_region().shape[1])) + 0.5f) * hr - 0.5f;
-
- shape.set(0, shape_out_x - anchor[0]);
- shape.set(1, shape_out_y - anchor[1]);
-
- return valid_region;
-}
-
inline Coordinates index2coords(const TensorShape &shape, int index)
{
int num_elements = shape.total_size();
diff --git a/src/core/CL/kernels/CLScaleKernel.cpp b/src/core/CL/kernels/CLScaleKernel.cpp
index f3d918514e..9b8a582349 100644
--- a/src/core/CL/kernels/CLScaleKernel.cpp
+++ b/src/core/CL/kernels/CLScaleKernel.cpp
@@ -102,7 +102,7 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo
output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()),
output->info()->tensor_shape(),
policy,
- border,
+ sampling_policy,
border_undefined));
ICLKernel::configure(win);
diff --git a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
index 46d7ff9172..f87615a27c 100644
--- a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
@@ -51,7 +51,6 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo
ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
ARM_COMPUTE_ERROR_ON(output == input);
ARM_COMPUTE_ERROR_ON(policy != InterpolationPolicy::NEAREST_NEIGHBOR);
- ARM_COMPUTE_UNUSED(sampling_policy);
_input = input;
_output = output;
@@ -123,7 +122,7 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo
output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()),
output->info()->tensor_shape(),
policy,
- border,
+ sampling_policy,
border_undefined));
IGCKernel::configure(win);
diff --git a/src/core/Helpers.cpp b/src/core/Helpers.cpp
index 0e7cd99eab..c39922bf03 100644
--- a/src/core/Helpers.cpp
+++ b/src/core/Helpers.cpp
@@ -173,3 +173,75 @@ Window arm_compute::calculate_max_window_horizontal(const ValidRegion &valid_reg
return window;
}
+
+ValidRegion arm_compute::calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape,
+ InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined)
+{
+ const float scale_x = static_cast<float>(dst_shape[0]) / src_info.tensor_shape()[0];
+ const float scale_y = static_cast<float>(dst_shape[1]) / src_info.tensor_shape()[1];
+ const float sampling_point = (sampling_policy == SamplingPolicy::CENTER) ? 0.5f : 0.0f;
+
+ // Get input's valid region start and end points
+ const int valid_start_in_x = src_info.valid_region().anchor[0];
+ const int valid_start_in_y = src_info.valid_region().anchor[1];
+ const int valid_end_in_x = src_info.valid_region().anchor[0] + src_info.valid_region().shape[0];
+ const int valid_end_in_y = src_info.valid_region().anchor[1] + src_info.valid_region().shape[1];
+
+ // Initialize output's valid region start and end points
+ auto valid_start_out_x = static_cast<int>(valid_start_in_x * scale_x);
+ auto valid_start_out_y = static_cast<int>(valid_start_in_y * scale_y);
+ auto valid_end_out_x = std::min<int>(std::ceil(valid_end_in_x * scale_x), dst_shape[0]);
+ auto valid_end_out_y = std::min<int>(std::ceil(valid_end_in_y * scale_y), dst_shape[1]);
+
+ // Handle valid points in case of the bi-linear interpolation
+ if(border_undefined)
+ {
+ switch(interpolate_policy)
+ {
+ case InterpolationPolicy::NEAREST_NEIGHBOR:
+ {
+ // (start_out + sampling_point) >= (start_in * scale)
+ // start_out = ceil((start_in * scale) - sampling_point)
+ valid_start_out_x = std::ceil(valid_start_in_x * scale_x - sampling_point);
+ valid_start_out_y = std::ceil(valid_start_in_y * scale_y - sampling_point);
+
+ // (end_out - 1 + sampling_point) < (end_in * scale)
+ // end_out = ceil((end_in * scale) - sampling_point); // <-- ceil(x - 1) strictly less
+ valid_end_out_x = std::ceil(valid_end_in_x * scale_x - sampling_point);
+ valid_end_out_y = std::ceil(valid_end_in_y * scale_y - sampling_point);
+ break;
+ }
+ case InterpolationPolicy::BILINEAR:
+ {
+ // (start_out + sampling_point) >= ((start_in + sampling_point) * scale)
+ // start_out = ceil(((start_in + sampling_point) * scale) - sampling_point)
+ valid_start_out_x = std::ceil((valid_start_in_x + sampling_point) * scale_x - sampling_point);
+ valid_start_out_y = std::ceil((valid_start_in_y + sampling_point) * scale_y - sampling_point);
+
+ // (end_out - 1 + sampling_point) <= ((end_in - 1 + sampling_point) * scale)
+ // end_out = floor(((end_in - 1 + sampling_point) * scale) - sampling_point + 1)
+ valid_end_out_x = std::floor((valid_end_in_x - 1.f + sampling_point) * scale_x - sampling_point + 1.f);
+ valid_end_out_y = std::floor((valid_end_in_y - 1.f + sampling_point) * scale_y - sampling_point + 1.f);
+ break;
+ }
+ case InterpolationPolicy::AREA:
+ break;
+ default:
+ {
+ ARM_COMPUTE_ERROR("Invalid InterpolationPolicy");
+ break;
+ }
+ }
+ }
+
+ // Setup output valid region
+ ValidRegion valid_region{ Coordinates(), dst_shape, src_info.tensor_shape().num_dimensions() };
+
+ valid_region.anchor.set(0, std::max(0, valid_start_out_x));
+ valid_region.anchor.set(1, std::max(0, valid_start_out_y));
+
+ valid_region.shape.set(0, std::min<size_t>(valid_end_out_x - valid_start_out_x, dst_shape[0]));
+ valid_region.shape.set(1, std::min<size_t>(valid_end_out_y - valid_start_out_y, dst_shape[1]));
+
+ return valid_region;
+} \ No newline at end of file
diff --git a/src/core/NEON/kernels/NEScaleKernel.cpp b/src/core/NEON/kernels/NEScaleKernel.cpp
index b5677dedac..852ec3e023 100644
--- a/src/core/NEON/kernels/NEScaleKernel.cpp
+++ b/src/core/NEON/kernels/NEScaleKernel.cpp
@@ -142,7 +142,11 @@ void NEScaleKernel::configure(const ITensor *input, const ITensor *dx, const ITe
dy_access,
output_access);
- output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()), output->info()->tensor_shape(), policy, border_size(), border_undefined));
+ output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()),
+ output->info()->tensor_shape(),
+ policy,
+ sampling_policy,
+ border_undefined));
INEKernel::configure(win);
}
diff --git a/tests/validation/CL/Scale.cpp b/tests/validation/CL/Scale.cpp
index c7a8e2ab6e..cc4fdb0564 100644
--- a/tests/validation/CL/Scale.cpp
+++ b/tests/validation/CL/Scale.cpp
@@ -58,8 +58,10 @@ const auto ScaleDataTypes = framework::dataset::make("DataType",
/** Tolerance */
constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
-RelativeTolerance<float> tolerance_f32(0.05);
-RelativeTolerance<half> tolerance_f16(half(0.1));
+constexpr float tolerance_f32_absolute(0.001f);
+
+RelativeTolerance<float> tolerance_f32(0.05);
+RelativeTolerance<half> tolerance_f16(half(0.1));
constexpr float tolerance_num_f32(0.01f);
} // namespace
@@ -98,7 +100,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
// Validate valid region
- const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, border_size, (border_mode == BorderMode::UNDEFINED));
+ const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, sampling_policy, (border_mode == BorderMode::UNDEFINED));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -123,10 +125,10 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<float>, framework::DatasetMode::
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
+ validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
}
FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)),
framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
@@ -135,10 +137,10 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
+ validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
}
TEST_SUITE_END()
TEST_SUITE(FP16)
@@ -149,7 +151,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<half>, framework::DatasetMode::A
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -162,7 +164,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::N
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -179,7 +181,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<uint8_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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_u8);
@@ -191,7 +193,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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_u8);
@@ -205,7 +207,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<int16_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -218,7 +220,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
diff --git a/tests/validation/GLES_COMPUTE/Scale.cpp b/tests/validation/GLES_COMPUTE/Scale.cpp
index 16280faf3e..9f670e4d4d 100644
--- a/tests/validation/GLES_COMPUTE/Scale.cpp
+++ b/tests/validation/GLES_COMPUTE/Scale.cpp
@@ -90,7 +90,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
// Validate valid region
- const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, border_size, (border_mode == BorderMode::UNDEFINED));
+ const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, sampling_policy, (border_mode == BorderMode::UNDEFINED));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -115,7 +115,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, GCScaleFixture<half>, framework::DatasetMode::A
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
// Validate output
validate(GCAccessor(_target), _reference, valid_region, tolerance_f16);
@@ -128,7 +128,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, GCScaleFixture<half>, framework::DatasetMode::N
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
// Validate output
validate(GCAccessor(_target), _reference, valid_region, tolerance_f16);
diff --git a/tests/validation/NEON/Scale.cpp b/tests/validation/NEON/Scale.cpp
index d860823430..5f76a0ca06 100644
--- a/tests/validation/NEON/Scale.cpp
+++ b/tests/validation/NEON/Scale.cpp
@@ -99,7 +99,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi
nescale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
// Validate valid region
- const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED));
+ const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, sampling_policy, (border_mode == BorderMode::UNDEFINED));
validate(dst.info()->valid_region(), dst_valid_region);
@@ -126,7 +126,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -139,7 +139,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<float>, framework::DatasetMode::
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -157,7 +157,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -170,7 +170,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<uint8_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -185,7 +185,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
@@ -198,7 +198,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<int16_t>, framework::DatasetMode
{
//Create valid region
TensorInfo src_info(_shape, 1, _data_type);
- ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED));
+ 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);
diff --git a/tests/validation/fixtures/ScaleFixture.h b/tests/validation/fixtures/ScaleFixture.h
index fe24f5bac5..604bfb2622 100644
--- a/tests/validation/fixtures/ScaleFixture.h
+++ b/tests/validation/fixtures/ScaleFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -74,7 +74,16 @@ protected:
template <typename U>
void fill(U &&tensor)
{
- library->fill_tensor_uniform(tensor, 0);
+ if(is_data_type_float(_data_type))
+ {
+ library->fill_tensor_uniform(tensor, 0);
+ }
+ else
+ {
+ // Restrict range for float to avoid any floating point issues
+ std::uniform_real_distribution<> distribution(-5.0f, 5.0f);
+ library->fill(tensor, distribution, 0);
+ }
}
TensorType compute_target(const TensorShape &shape, const float scale_x, const float scale_y,