From 565bf2d88df1790373f0ff92b8cc9e90dbf28d11 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 31 Aug 2018 11:46:49 +0100 Subject: COMPMID-1514: Add validate to NEFloor and CLFloor COMPMID-1515: Add FP16 support to NEFloor and CLFloor Change-Id: Ib63a62c7681056ee13be99ce081b4d3949da4217 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/146547 Tested-by: Jenkins Reviewed-by: Pablo Tello --- arm_compute/core/CL/kernels/CLFloorKernel.h | 14 ++++- arm_compute/core/NEON/NEMath.inl | 9 +++ arm_compute/core/NEON/kernels/NEFloorKernel.h | 13 +++- arm_compute/runtime/CL/functions/CLFloor.h | 14 ++++- arm_compute/runtime/NEON/functions/NEFloor.h | 14 ++++- src/core/CL/kernels/CLFloorKernel.cpp | 62 ++++++++++++++---- src/core/NEON/kernels/NEFloorKernel.cpp | 91 ++++++++++++++++++++++----- src/runtime/CL/functions/CLFloor.cpp | 12 +++- src/runtime/NEON/functions/NEFloor.cpp | 12 +++- tests/validation/CL/Floor.cpp | 47 ++++++++++++-- tests/validation/NEON/Floor.cpp | 45 ++++++++++++- tests/validation/reference/Floor.cpp | 3 +- 12 files changed, 284 insertions(+), 52 deletions(-) diff --git a/arm_compute/core/CL/kernels/CLFloorKernel.h b/arm_compute/core/CL/kernels/CLFloorKernel.h index ffe699e280..930d90f903 100644 --- a/arm_compute/core/CL/kernels/CLFloorKernel.h +++ b/arm_compute/core/CL/kernels/CLFloorKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -48,10 +48,18 @@ public: ~CLFloorKernel() = default; /** Set the source, destination of the kernel * - * @param[in] input Source tensor. Data type supported: F32. - * @param[out] output Destination tensor. Data type supported: F32. + * @param[in] input Source tensor. Data type supported: F16/F32. + * @param[out] output Destination tensor. Same as @p input */ void configure(const ICLTensor *input, ICLTensor *output); + /** Static function to check if given info will lead to a valid configuration of @ref CLFloorKernel + * + * @param[in] input Source tensor info. Data type supported: F16/F32. + * @param[in] output Destination tensor info. Same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; diff --git a/arm_compute/core/NEON/NEMath.inl b/arm_compute/core/NEON/NEMath.inl index 1ebc9c10af..2bc1ab7964 100644 --- a/arm_compute/core/NEON/NEMath.inl +++ b/arm_compute/core/NEON/NEMath.inl @@ -175,6 +175,15 @@ inline float32x4_t vpowq_f32(float32x4_t val, float32x4_t n) /** Exponent polynomial coefficients */ /** Logarithm polynomial coefficients */ #ifndef DOXYGEN_SKIP_THIS +inline float16x8_t vfloorq_f16(float16x8_t val) +{ + static const float16x8_t CONST_1 = vdupq_n_f16(1.f); + + const int16x8_t z = vcvtq_s16_f16(val); + const float16x8_t r = vcvtq_f16_s16(z); + + return vbslq_f16(vcgtq_f16(r, val), vsubq_f16(r, CONST_1), r); +} inline float16x4_t vinvsqrt_f16(float16x4_t x) { float16x4_t sqrt_reciprocal = vrsqrte_f16(x); diff --git a/arm_compute/core/NEON/kernels/NEFloorKernel.h b/arm_compute/core/NEON/kernels/NEFloorKernel.h index b72d0527cc..6269430ddc 100644 --- a/arm_compute/core/NEON/kernels/NEFloorKernel.h +++ b/arm_compute/core/NEON/kernels/NEFloorKernel.h @@ -40,10 +40,19 @@ public: } /** Set the source, destination of the kernel * - * @param[in] input Source tensor. Data type supported: F32. - * @param[out] output Destination tensor. Data type supported: F32. + * @param[in] input Source tensor. Data type supported: F16/F32. + * @param[out] output Destination tensor. Same as @p input */ void configure(const ITensor *input, ITensor *output); + /** Static function to check if given info will lead to a valid configuration of @ref NEFloorKernel + * + * @param[in] input Source tensor info. Data type supported: F16/F32. + * @param[in] output Destination tensor info. Same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); + // Inherited methods overridden: void run(const Window &window, const ThreadInfo &info) override; }; diff --git a/arm_compute/runtime/CL/functions/CLFloor.h b/arm_compute/runtime/CL/functions/CLFloor.h index bee686a526..5e8368e1a7 100644 --- a/arm_compute/runtime/CL/functions/CLFloor.h +++ b/arm_compute/runtime/CL/functions/CLFloor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -38,10 +38,18 @@ class CLFloor : public ICLSimpleFunction public: /** Set the source, destination of the kernel * - * @param[in] input Source tensor. Data type supported: F32. - * @param[out] output Destination tensor. Data type supported: F32. + * @param[in] input Source tensor. Data type supported: F16/F32. + * @param[out] output Destination tensor. Same as @p input */ void configure(const ICLTensor *input, ICLTensor *output); + /** Static function to check if given info will lead to a valid configuration of @ref CLFloor + * + * @param[in] input Source tensor info. Data type supported: F16/F32. + * @param[in] output Destination tensor info. Same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); }; } #endif /* __ARM_COMPUTE_CLFLOOR_H__ */ diff --git a/arm_compute/runtime/NEON/functions/NEFloor.h b/arm_compute/runtime/NEON/functions/NEFloor.h index 6cd10ee1b9..92aa994ee3 100644 --- a/arm_compute/runtime/NEON/functions/NEFloor.h +++ b/arm_compute/runtime/NEON/functions/NEFloor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -38,10 +38,18 @@ class NEFloor : public INESimpleFunction public: /** Set the source, destination of the kernel * - * @param[in] input Source tensor. Data type supported: F32. - * @param[out] output Destination tensor. Data type supported: F32. + * @param[in] input Source tensor. Data type supported: F16/F32. + * @param[out] output Destination tensor. Same as @p input */ void configure(const ITensor *input, ITensor *output); + /** Static function to check if given info will lead to a valid configuration of @ref NEFloor + * + * @param[in] input Source tensor info. Data type supported: F16/F32. + * @param[in] output Destination tensor info. Same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); }; } #endif /* __ARM_COMPUTE_NEFLOOR_H__ */ diff --git a/src/core/CL/kernels/CLFloorKernel.cpp b/src/core/CL/kernels/CLFloorKernel.cpp index 20e3a3a66f..831173d076 100644 --- a/src/core/CL/kernels/CLFloorKernel.cpp +++ b/src/core/CL/kernels/CLFloorKernel.cpp @@ -25,6 +25,7 @@ #include "arm_compute/core/CL/CLHelpers.h" #include "arm_compute/core/CL/CLKernelLibrary.h" +#include "arm_compute/core/CL/CLValidate.h" #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/Helpers.h" #include "arm_compute/core/IAccessWindow.h" @@ -33,7 +34,42 @@ #include "arm_compute/core/Validate.h" #include "arm_compute/core/Window.h" -using namespace arm_compute; +namespace arm_compute +{ +namespace +{ +Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); + ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input); + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32); + + // Validate in case of configured output + if(output->total_size() > 0) + { + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); + } + + return Status{}; +} + +std::pair validate_and_configure_window(ITensorInfo *input, ITensorInfo *output) +{ + auto_init_if_empty(*output, *input); + + const unsigned int num_elems_processed_per_iteration = 16 / input->element_size(); + + Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); + bool window_changed = update_window_and_padding(win, input_access, output_access); + output_access.set_valid_region(win, input->valid_region()); + + Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; + return std::make_pair(err, win); +} +} // namespace CLFloorKernel::CLFloorKernel() : _input(nullptr), _output(nullptr) @@ -47,14 +83,13 @@ void CLFloorKernel::configure(const ICLTensor *input, ICLTensor *output) // Auto initialize output auto_init_if_empty(*output->info(), input->info()->tensor_shape(), 1, input->info()->data_type()); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input, output); - ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); + // Validate + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info())); _input = input; _output = output; - constexpr unsigned int num_elems_processed_per_iteration = 4; + const unsigned int num_elems_processed_per_iteration = 16 / input->info()->element_size(); // Create kernel std::set build_opts; @@ -63,13 +98,17 @@ void CLFloorKernel::configure(const ICLTensor *input, ICLTensor *output) _kernel = static_cast(CLKernelLibrary::get().create_kernel("floor_layer", build_opts)); // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); - update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, input->info()->valid_region()); + auto win_config = validate_and_configure_window(input->info(), output->info()); + ARM_COMPUTE_ERROR_THROW_ON(win_config.first); + ICLKernel::configure_internal(win_config.second); +} + +Status CLFloorKernel::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output)); + ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first); - ICLKernel::configure_internal(win); + return Status{}; } void CLFloorKernel::run(const Window &window, cl::CommandQueue &queue) @@ -89,3 +128,4 @@ void CLFloorKernel::run(const Window &window, cl::CommandQueue &queue) } while(collapsed.slide_window_slice_3D(slice)); } +} // namespace arm_compute \ No newline at end of file diff --git a/src/core/NEON/kernels/NEFloorKernel.cpp b/src/core/NEON/kernels/NEFloorKernel.cpp index 872ac2661e..6551d9ed57 100644 --- a/src/core/NEON/kernels/NEFloorKernel.cpp +++ b/src/core/NEON/kernels/NEFloorKernel.cpp @@ -23,6 +23,7 @@ */ #include "arm_compute/core/NEON/kernels/NEFloorKernel.h" +#include "arm_compute/core/CPP/Validate.h" #include "arm_compute/core/Coordinates.h" #include "arm_compute/core/Helpers.h" #include "arm_compute/core/IAccessWindow.h" @@ -33,7 +34,42 @@ #include -using namespace arm_compute; +namespace arm_compute +{ +namespace +{ +Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); + ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input); + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32); + + // Validate in case of configured output + if(output->total_size() > 0) + { + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); + } + + return Status{}; +} + +std::pair validate_and_configure_window(ITensorInfo *input, ITensorInfo *output) +{ + auto_init_if_empty(*output, *input); + + const unsigned int num_elems_processed_per_iteration = 16 / input->element_size(); + + Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); + bool window_changed = update_window_and_padding(win, input_access, output_access); + output_access.set_valid_region(win, input->valid_region()); + + Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; + return std::make_pair(err, win); +} +} // namespace void NEFloorKernel::configure(const ITensor *input, ITensor *output) { @@ -42,24 +78,24 @@ void NEFloorKernel::configure(const ITensor *input, ITensor *output) // Auto initialize output auto_init_if_empty(*output->info(), input->info()->tensor_shape(), 1, input->info()->data_type()); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input, output); - ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); + // Validate + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info())); _input = input; _output = output; - constexpr unsigned int num_elems_processed_per_iteration = 4; - // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); + auto win_config = validate_and_configure_window(input->info(), output->info()); + ARM_COMPUTE_ERROR_THROW_ON(win_config.first); + INEKernel::configure(win_config.second); +} - update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, input->info()->valid_region()); +Status NEFloorKernel::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output)); + ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first); - INEKernel::configure(win); + return Status{}; } void NEFloorKernel::run(const Window &window, const ThreadInfo &info) @@ -68,13 +104,34 @@ void NEFloorKernel::run(const Window &window, const ThreadInfo &info) ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); + const DataType data_type = _input->info()->data_type(); + Iterator input(_input, window); Iterator output(_output, window); - execute_window_loop(window, [&](const Coordinates & id) + if(data_type == DataType::F32) + { + execute_window_loop(window, [&](const Coordinates & id) + { + const float32x4_t res = vfloorq_f32(vld1q_f32(reinterpret_cast(input.ptr()))); + vst1q_f32(reinterpret_cast(output.ptr()), res); + }, + input, output); + } +#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC + else if(data_type == DataType::F16) + { + execute_window_loop(window, [&](const Coordinates & id) + { + const float16x8_t res = vfloorq_f16(vld1q_f16(reinterpret_cast(input.ptr()))); + vst1q_f16(reinterpret_cast(output.ptr()), res); + }, + input, output); + } +#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC + else { - const float32x4_t res = vfloorq_f32(vld1q_f32(reinterpret_cast(input.ptr()))); - vst1q_f32(reinterpret_cast(output.ptr()), res); - }, - input, output); + ARM_COMPUTE_ERROR("Invalid data type!"); + } } +} // namespace arm_compute diff --git a/src/runtime/CL/functions/CLFloor.cpp b/src/runtime/CL/functions/CLFloor.cpp index 364db349c1..4137071f5f 100644 --- a/src/runtime/CL/functions/CLFloor.cpp +++ b/src/runtime/CL/functions/CLFloor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -26,11 +26,17 @@ #include "arm_compute/core/CL/kernels/CLFloorKernel.h" #include "support/ToolchainSupport.h" -using namespace arm_compute; - +namespace arm_compute +{ void CLFloor::configure(const ICLTensor *input, ICLTensor *output) { auto k = arm_compute::support::cpp14::make_unique(); k->configure(input, output); _kernel = std::move(k); } + +Status CLFloor::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + return CLFloorKernel::validate(input, output); +} +} // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEFloor.cpp b/src/runtime/NEON/functions/NEFloor.cpp index 0000cddfbd..817918808e 100644 --- a/src/runtime/NEON/functions/NEFloor.cpp +++ b/src/runtime/NEON/functions/NEFloor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -26,11 +26,17 @@ #include "arm_compute/core/NEON/kernels/NEFloorKernel.h" #include "support/ToolchainSupport.h" -using namespace arm_compute; - +namespace arm_compute +{ void NEFloor::configure(const ITensor *input, ITensor *output) { auto k = arm_compute::support::cpp14::make_unique(); k->configure(input, output); _kernel = std::move(k); } + +Status NEFloor::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + return NEFloorKernel::validate(input, output); +} +} // namespace arm_compute diff --git a/tests/validation/CL/Floor.cpp b/tests/validation/CL/Floor.cpp index b8a93f0d99..ef53b4117f 100644 --- a/tests/validation/CL/Floor.cpp +++ b/tests/validation/CL/Floor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -43,9 +43,47 @@ namespace validation TEST_SUITE(CL) TEST_SUITE(Floor) +// *INDENT-OFF* +// clang-format off +DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip( + framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Wrong data type + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Invalid data type combination + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + }), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + })), + framework::dataset::make("Expected", { false, false, false, false, true })), + input_info, output_info, expected) +{ + const Status status = CLFloor::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false)); + ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); +} +// clang-format on +// *INDENT-ON* + template using CLFloorFixture = FloorValidationFixture; +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() // FP16 + TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE(RunSmall, CLFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) { @@ -57,10 +95,11 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLFloorFixture, framework::DatasetMode:: // Validate output validate(CLAccessor(_target), _reference); } -TEST_SUITE_END() +TEST_SUITE_END() // FP32 +TEST_SUITE_END() // Float -TEST_SUITE_END() -TEST_SUITE_END() +TEST_SUITE_END() // Floor +TEST_SUITE_END() // CL } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/NEON/Floor.cpp b/tests/validation/NEON/Floor.cpp index c14b859e89..540da570bb 100644 --- a/tests/validation/NEON/Floor.cpp +++ b/tests/validation/NEON/Floor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -43,9 +43,49 @@ namespace validation TEST_SUITE(NEON) TEST_SUITE(Floor) +// *INDENT-OFF* +// clang-format off +DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip( + framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Wrong data type + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Invalid data type combination + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + }), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F16), + TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), + })), + framework::dataset::make("Expected", { false, false, false, false, true })), + input_info, output_info, expected) +{ + const Status status = NEFloor::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false)); + ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); +} +// clang-format on +// *INDENT-ON* + template using NEFloorFixture = FloorValidationFixture; +TEST_SUITE(Float) +#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() // FP16 +#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC + TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE(RunSmall, NEFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) { @@ -57,7 +97,8 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEFloorFixture, framework::DatasetMode:: // Validate output validate(Accessor(_target), _reference); } -TEST_SUITE_END() +TEST_SUITE_END() // FP32 +TEST_SUITE_END() // Float TEST_SUITE_END() TEST_SUITE_END() diff --git a/tests/validation/reference/Floor.cpp b/tests/validation/reference/Floor.cpp index 1c739448b7..b011a16974 100644 --- a/tests/validation/reference/Floor.cpp +++ b/tests/validation/reference/Floor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -50,6 +50,7 @@ SimpleTensor floor_layer(const SimpleTensor &src) return dst; } +template SimpleTensor floor_layer(const SimpleTensor &src); template SimpleTensor floor_layer(const SimpleTensor &src); } // namespace reference } // namespace validation -- cgit v1.2.1