diff options
author | John Richardson <john.richardson@arm.com> | 2017-09-18 16:10:48 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | dd715f2a88827241a3fb9e4a2d8be82455f649f7 (patch) | |
tree | 2353cbe326073870877e5e8211a7760a743eb919 /tests | |
parent | f5f34bb068565bf9435ba5561aae1c9280db8bbe (diff) | |
download | ComputeLibrary-dd715f2a88827241a3fb9e4a2d8be82455f649f7.tar.gz |
COMPMID-505: Move PixelWiseMultiplication to new validation
Change-Id: I4daff53f5ee7f0393451425ba20aee1013466954
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/89200
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests')
18 files changed, 1097 insertions, 975 deletions
diff --git a/tests/validation/CL/PixelWiseMultiplication.cpp b/tests/validation/CL/PixelWiseMultiplication.cpp new file mode 100644 index 0000000000..66f3ff6375 --- /dev/null +++ b/tests/validation/CL/PixelWiseMultiplication.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/CL/functions/CLPixelWiseMultiplication.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ConvertPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FixedPointPixelWiseMultiplicationFixture.h" +#include "tests/validation/fixtures/PixelWiseMultiplicationFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +const float scale_unity = 1.f; +const float scale_255 = 1.f / 255.f; + +// *INDENT-OFF* +// clang-format off +#define WRAP_VALIDATE(TYPE, TOLERANCE) validate_wrap(CLAccessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f); + +#define PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, SCALE, RP, VALIDATE) \ + FIXTURE_DATA_TEST_CASE(TEST_NAME, CLPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \ + combine(combine(combine(combine(combine( \ + datasets::SHAPES, \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", std::move(SCALE))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP))) \ + { \ + VALIDATE \ + } + +#define FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, SCALE, RP, FPP_START, FPP_END) \ + FIXTURE_DATA_TEST_CASE(TEST_NAME, CLFixedPointPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \ + combine(combine(combine(combine(combine(combine( \ + datasets::SHAPES, \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", std::move(SCALE))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \ + framework::dataset::make("FixedPointPosition", FPP_START, FPP_END))) \ + { \ + validate(CLAccessor(_target), _reference); \ + } +// clang-format on +// *INDENT-ON* +} // namespace + +template <typename T> +using CLPixelWiseMultiplicationToF16Fixture = PixelWiseMultiplicationValidationFixture<CLTensor, CLAccessor, CLPixelWiseMultiplication, T, half_float::half>; +template <typename T> +using CLPixelWiseMultiplicationToF32Fixture = PixelWiseMultiplicationValidationFixture<CLTensor, CLAccessor, CLPixelWiseMultiplication, T, float>; +template <typename T> +using CLPixelWiseMultiplicationToQS8Fixture = PixelWiseMultiplicationValidationFixture<CLTensor, CLAccessor, CLPixelWiseMultiplication, T, qint8_t>; +template <typename T> +using CLPixelWiseMultiplicationToQS16Fixture = PixelWiseMultiplicationValidationFixture<CLTensor, CLAccessor, CLPixelWiseMultiplication, T, qint16_t>; +template <typename T> +using CLFixedPointPixelWiseMultiplicationFixture = FixedPointPixelWiseMultiplicationValidationFixture<CLTensor, CLAccessor, CLPixelWiseMultiplication, T>; + +TEST_SUITE(CL) +TEST_SUITE(PixelWiseMultiplication) + +TEST_SUITE(F16toF16) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF16Fixture<half_float::half>, PRECOMMIT, SmallShapes(), F16, F16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(float, 1.f)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE_END() // F16toF16 + +TEST_SUITE(F32toF32) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, PRECOMMIT, SmallShapes(), F32, F32, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(float, 1.f)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE_END() // F32toF32 + +TEST_SUITE_END() // PixelWiseMultiplication + +TEST_SUITE(FixedPointPixelWiseMultiplication) + +TEST_SUITE(QS8) + +TEST_SUITE(ScaleUnity) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, scale_unity, TO_ZERO, 1, 7) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE_END() // QS8 + +TEST_SUITE(QS16) + +TEST_SUITE(ScaleUnity) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, scale_unity, TO_ZERO, 1, 15) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE_END() // QS16 + +TEST_SUITE_END() // FixedPointPixelWiseMultiplication +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/FixedPointPixelWiseMultiplication.cpp b/tests/validation/CPP/FixedPointPixelWiseMultiplication.cpp new file mode 100644 index 0000000000..636919b1ff --- /dev/null +++ b/tests/validation/CPP/FixedPointPixelWiseMultiplication.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * dst OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "FixedPointPixelWiseMultiplication.h" + +#include "tests/validation/FixedPoint.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <typename T> +SimpleTensor<T> fixed_point_pixel_wise_multiplication(const SimpleTensor<T> &src1, const SimpleTensor<T> &src2, float scale, ConvertPolicy convert_policy) +{ + using namespace fixed_point_arithmetic; + + SimpleTensor<T> dst(src2.shape(), src2.data_type(), 1, src2.fixed_point_position()); + + const int fixed_point_position = src1.fixed_point_position(); + + ARM_COMPUTE_ERROR_ON_MSG(src1.data_type() != src2.data_type() || src1.data_type() != dst.data_type(), + "Tensors must all have the same DataType"); + ARM_COMPUTE_ERROR_ON_MSG(fixed_point_position != src2.fixed_point_position() || fixed_point_position != dst.fixed_point_position(), + "Fixed-point position must be the same for both inputs and outputs"); + + // Validate fixed_point_position + ARM_COMPUTE_ERROR_ON((src1.data_type() == DataType::QS8) && (fixed_point_position == 0 || fixed_point_position > 7)); + ARM_COMPUTE_ERROR_ON((src1.data_type() == DataType::QS16) && (fixed_point_position == 0 || fixed_point_position > 15)); + + const fixed_point<T> fp_scale(scale, fixed_point_position); + const bool is_sat = convert_policy == ConvertPolicy::SATURATE; + + for(int i = 0; i < src1.num_elements(); ++i) + { + const fixed_point<T> val1(src1[i], fixed_point_position, true); + fixed_point<T> res(src2[i], fixed_point_position, true); + if(is_sat) + { + res = mul(mul(res, val1), fp_scale); + } + else + { + res = mul<OverflowPolicy::WRAP>(mul<OverflowPolicy::WRAP>(res, val1), fp_scale); + } + dst[i] = res.raw(); + } + + return dst; +} + +// *INDENT-OFF* +// clang-format off +template SimpleTensor<qint8_t> fixed_point_pixel_wise_multiplication(const SimpleTensor<qint8_t> &src1, const SimpleTensor<qint8_t> &src2, float scale, ConvertPolicy convert_policy); +template SimpleTensor<qint16_t> fixed_point_pixel_wise_multiplication(const SimpleTensor<qint16_t> &src1, const SimpleTensor<qint16_t> &src2, float scale, ConvertPolicy convert_policy); +// *INDENT-ON* +// clang-format on + +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/FixedPointPixelWiseMultiplication.h b/tests/validation/CPP/FixedPointPixelWiseMultiplication.h new file mode 100644 index 0000000000..124a33c9da --- /dev/null +++ b/tests/validation/CPP/FixedPointPixelWiseMultiplication.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_H__ +#define __ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <typename T> +SimpleTensor<T> fixed_point_pixel_wise_multiplication(const SimpleTensor<T> &src1, const SimpleTensor<T> &src2, float scale, ConvertPolicy convert_policy); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_H__ */ diff --git a/tests/validation/CPP/PixelWiseMultiplication.cpp b/tests/validation/CPP/PixelWiseMultiplication.cpp new file mode 100644 index 0000000000..b3647fc9ce --- /dev/null +++ b/tests/validation/CPP/PixelWiseMultiplication.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * dst OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "PixelWiseMultiplication.h" + +#include "tests/validation/FixedPoint.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <class T> +struct is_floating_point + : std::integral_constant < bool, + std::is_same<float, typename std::remove_cv<T>::type>::value || std::is_same<half_float::half, typename std::remove_cv<T>::type>::value + || std::is_same<double, typename std::remove_cv<T>::type>::value || std::is_same<long double, typename std::remove_cv<T>::type>::value > +{ +}; + +template <typename T1, typename T2> +SimpleTensor<T2> pixel_wise_multiplication(const SimpleTensor<T1> &src1, const SimpleTensor<T2> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + SimpleTensor<T2> dst(src2.shape(), src2.data_type()); + + if(scale < 0) + { + ARM_COMPUTE_ERROR("Scale of pixel-wise multiplication must be non-negative"); + } + + using intermediate_type = typename common_promoted_signed_type<T1, T2, T2>::intermediate_type; + + for(int i = 0; i < src1.num_elements(); ++i) + { + double val = static_cast<intermediate_type>(src1[i]) * static_cast<intermediate_type>(src2[i]) * static_cast<double>(scale); + if(is_floating_point<T2>::value) + { + dst[i] = val; + } + else + { + double rounded_val = 0; + switch(rounding_policy) + { + case(RoundingPolicy::TO_ZERO): + rounded_val = support::cpp11::trunc(val); + break; + case(RoundingPolicy::TO_NEAREST_UP): + rounded_val = round_half_up(val); + break; + case(RoundingPolicy::TO_NEAREST_EVEN): + rounded_val = round_half_even(val); + break; + default: + ARM_COMPUTE_ERROR("Unsupported rounding policy"); + } + + dst[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast<T2>(rounded_val) : static_cast<T2>(rounded_val); + } + } + + return dst; +} + +// *INDENT-OFF* +// clang-format off +template SimpleTensor<uint8_t> pixel_wise_multiplication(const SimpleTensor<uint8_t> &src1, const SimpleTensor<uint8_t> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +template SimpleTensor<int16_t> pixel_wise_multiplication(const SimpleTensor<uint8_t> &src1, const SimpleTensor<int16_t> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +template SimpleTensor<int16_t> pixel_wise_multiplication(const SimpleTensor<int16_t> &src1, const SimpleTensor<int16_t> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +template SimpleTensor<float> pixel_wise_multiplication(const SimpleTensor<float> &src1, const SimpleTensor<float> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +template SimpleTensor<half_float::half> pixel_wise_multiplication(const SimpleTensor<half_float::half> &src1, const SimpleTensor<half_float::half> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +// clang-format on +// *INDENT-ON* +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/PixelWiseMultiplication.h b/tests/validation/CPP/PixelWiseMultiplication.h new file mode 100644 index 0000000000..1dce154719 --- /dev/null +++ b/tests/validation/CPP/PixelWiseMultiplication.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_H__ +#define __ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <typename T1, typename T2> +SimpleTensor<T2> pixel_wise_multiplication(const SimpleTensor<T1> &src1, const SimpleTensor<T2> &src2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_H__ */ diff --git a/tests/validation/NEON/FixedPointPixelWiseMultiplication.cpp b/tests/validation/NEON/FixedPointPixelWiseMultiplication.cpp new file mode 100644 index 0000000000..f0a499d8d1 --- /dev/null +++ b/tests/validation/NEON/FixedPointPixelWiseMultiplication.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" +#include "tests/NEON/Accessor.h" +#include "tests/datasets/ConvertPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FixedPointPixelWiseMultiplicationFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +const float tolerance = 1.f; +const float scale_255 = 1.f / 255.f; +const float scale_unity = 1.f; + +// *INDENT-OFF* +// clang-format off +#define FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, SCALE, RP, FPP_START, FPP_END) \ + FIXTURE_DATA_TEST_CASE(TEST_NAME, NEFixedPointPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \ + combine(combine(combine(combine(combine(combine( \ + datasets::SHAPES, \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", std::move(SCALE))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \ + framework::dataset::make("FixedPointPosition", FPP_START, FPP_END))) \ + { \ + validate(Accessor(_target), _reference); \ + } + +#define FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, RP, FPP, TOLERANCE) \ + FIXTURE_DATA_TEST_CASE(TEST_NAME, NEFixedPointPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \ + combine(combine(combine(combine(combine(combine( \ + datasets::SHAPES, \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", 1.f / static_cast<float>(1 << (FPP)))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \ + framework::dataset::make("FixedPointPosition", FPP))) \ + { \ + validate(Accessor(_target), _reference, AbsoluteTolerance<float>(TOLERANCE), 0.f); \ + } +// clang-format on +// *INDENT-ON* +} // namespace + +template <typename T> +using NEFixedPointPixelWiseMultiplicationFixture = FixedPointPixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T>; + +TEST_SUITE(NEON) +TEST_SUITE(FixedPointPixelWiseMultiplication) + +TEST_SUITE(QS8) + +TEST_SUITE(Scale255) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, scale_255, TO_NEAREST_UP, 1, 7) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, scale_255, TO_NEAREST_UP, 1, 7) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, scale_unity, TO_ZERO, 1, 7) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, scale_unity, TO_ZERO, 1, 7) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther1, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 1, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther2, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 2, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther3, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 3, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther4, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 4, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther5, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 5, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther6, Fixture<qint8_t>, PRECOMMIT, SmallShapes(), QS8, QS8, TO_ZERO, 6, tolerance) + +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther1, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 1, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther2, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 2, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther3, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 3, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther4, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 4, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther5, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 5, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunLargeOther6, Fixture<qint8_t>, NIGHTLY, LargeShapes(), QS8, QS8, TO_ZERO, 6, tolerance) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // QS8 + +TEST_SUITE(QS16) + +TEST_SUITE(Scale255) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, scale_255, TO_NEAREST_UP, 1, 15) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, scale_unity, TO_ZERO, 1, 15) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, Fixture<qint16_t>, NIGHTLY, LargeShapes(), QS16, QS16, scale_unity, TO_ZERO, 1, 15) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther1, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 1, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther2, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 2, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther3, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 3, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther4, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 4, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther5, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 5, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther6, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 6, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther7, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 7, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther8, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 8, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther9, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 9, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther10, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 10, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther11, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 11, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther12, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 12, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther13, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 13, tolerance) +FP_PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE_OTHER(RunSmallOther14, Fixture<qint16_t>, PRECOMMIT, SmallShapes(), QS16, QS16, TO_ZERO, 14, tolerance) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // QS16 + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/PixelWiseMultiplication.cpp b/tests/validation/NEON/PixelWiseMultiplication.cpp new file mode 100644 index 0000000000..e1e62e46ef --- /dev/null +++ b/tests/validation/NEON/PixelWiseMultiplication.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ConvertPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/PixelWiseMultiplicationFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +const float scale_unity = 1.f; +const float scale_255 = 1.f / 255.f; +const float scale_other = 1.f / 32768.f; + +#define DEFAULT_VALIDATE validate(Accessor(_target), _reference); +#define WRAP_VALIDATE(TYPE, TOLERANCE) validate_wrap(Accessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f); + +// *INDENT-OFF* +// clang-format off +#define PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(DT1, DT2, SCALE, RP) \ + DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, \ + combine(combine(combine(combine(combine( \ + concat(datasets::SmallShapes(), datasets::LargeShapes()), \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", std::move(SCALE))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \ + shape, dt1, dt2, scale, convert_policy, rounding_policy) \ + { \ + validate_configuration(shape, dt1, dt2, scale, convert_policy, rounding_policy); \ + } + +#define PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, SCALE, RP, VALIDATE) \ + FIXTURE_DATA_TEST_CASE(TEST_NAME, NEPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \ + combine(combine(combine(combine(combine( \ + datasets::SHAPES, \ + framework::dataset::make("DataType1", DataType::DT1)), \ + framework::dataset::make("DataType2", DataType::DT2)), \ + framework::dataset::make("Scale", std::move(SCALE))), \ + datasets::ConvertPolicies()), \ + framework::dataset::make("RoundingPolicy", RoundingPolicy::RP))) \ + { \ + VALIDATE \ + } +// *INDENT-ON* +// clang-format on + +void validate_configuration(TensorShape shape, DataType dt1, DataType dt2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + Tensor src1 = create_tensor<Tensor>(shape, dt1); + Tensor src2 = create_tensor<Tensor>(shape, dt2); + Tensor dst = create_tensor<Tensor>(shape, dt2); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEPixelWiseMultiplication multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +template <typename T> +using NEPixelWiseMultiplicationToU8Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, uint8_t>; +template <typename T> +using NEPixelWiseMultiplicationToS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, int16_t>; +template <typename T> +using NEPixelWiseMultiplicationToF16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, half_float::half>; +template <typename T> +using NEPixelWiseMultiplicationToF32Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, float>; +template <typename T> +using NEPixelWiseMultiplicationToQS8Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, qint8_t>; +template <typename T> +using NEPixelWiseMultiplicationToQS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, qint16_t>; + +TEST_SUITE(NEON) +TEST_SUITE(PixelWiseMultiplication) + +TEST_SUITE(U8toU8) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, U8, scale_255, TO_NEAREST_UP) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, U8, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(uint8_t, 1)) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToU8Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, U8, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(uint8_t, 1)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, U8, scale_unity, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, U8, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToU8Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, U8, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, U8, scale_other, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, U8, scale_other, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToU8Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, U8, scale_other, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // U8toU8 + +TEST_SUITE(U8toS16) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, S16, scale_255, TO_NEAREST_UP) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, S16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(int16_t, 2)) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, S16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(int16_t, 2)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, S16, scale_unity, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, S16, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, S16, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(U8, S16, scale_other, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, PRECOMMIT, SmallShapes(), U8, S16, scale_other, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<uint8_t>, NIGHTLY, LargeShapes(), U8, S16, scale_other, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // U8toS16 + +TEST_SUITE(S16toS16) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(S16, S16, scale_255, TO_NEAREST_UP) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, PRECOMMIT, SmallShapes(), S16, S16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(int16_t, 2)) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<int16_t>, NIGHTLY, LargeShapes(), S16, S16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(int16_t, 2)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(S16, S16, scale_unity, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, PRECOMMIT, SmallShapes(), S16, S16, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<int16_t>, NIGHTLY, LargeShapes(), S16, S16, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(S16, S16, scale_other, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, PRECOMMIT, SmallShapes(), S16, S16, scale_other, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToS16Fixture<int16_t>, NIGHTLY, LargeShapes(), S16, S16, scale_other, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // S16toS16 + +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(F16toF16) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF16Fixture<half_float::half>, PRECOMMIT, SmallShapes(), F16, F16, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(float, 1.f)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE_END() // F16toF16 +#endif // ARM_COMPUTE_ENABLE_FP16 + +TEST_SUITE(F32toF32) + +TEST_SUITE(Scale255) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(F32, F32, scale_255, TO_NEAREST_UP) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, PRECOMMIT, SmallShapes(), F32, F32, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(float, 1.f)) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToF32Fixture<float>, NIGHTLY, LargeShapes(), F32, F32, scale_255, TO_NEAREST_UP, WRAP_VALIDATE(float, 1.f)) +TEST_SUITE_END() // Scale255 + +TEST_SUITE(ScaleUnity) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(F32, F32, scale_unity, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, PRECOMMIT, SmallShapes(), F32, F32, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToF32Fixture<float>, NIGHTLY, LargeShapes(), F32, F32, scale_unity, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleUnity + +TEST_SUITE(ScaleOther) +PIXEL_WISE_MULTIPLICATION_DATA_TEST_CASE(F32, F32, scale_other, TO_ZERO) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, PRECOMMIT, SmallShapes(), F32, F32, scale_other, TO_ZERO, DEFAULT_VALIDATE) +PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunLarge, ToF32Fixture<float>, NIGHTLY, LargeShapes(), F32, F32, scale_other, TO_ZERO, DEFAULT_VALIDATE) +TEST_SUITE_END() // ScaleOther + +TEST_SUITE_END() // F32toF32 + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index f220224991..8ed98fbc82 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -235,14 +235,15 @@ void validate_keypoints(T target_first, T target_last, U reference_first, U refe template <typename T> struct compare_base { - compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0)) - : _target{ target }, _reference{ reference }, _tolerance{ tolerance } + compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0), bool wrap_range = false) + : _target{ target }, _reference{ reference }, _tolerance{ tolerance }, _wrap_range{ wrap_range } { } typename T::value_type _target{}; typename T::value_type _reference{}; T _tolerance{}; + bool _wrap_range{}; }; template <typename T> @@ -266,6 +267,12 @@ struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>> using comparison_type = typename std::conditional<std::is_integral<U>::value, int64_t, U>::type; + if(this->_wrap_range) + { + const comparison_type abs_difference(std::abs(static_cast<comparison_type>(this->_target)) - std::abs(static_cast<comparison_type>(this->_reference))); + return abs_difference <= static_cast<comparison_type>(this->_tolerance); + } + const comparison_type abs_difference(std::abs(static_cast<comparison_type>(this->_target) - static_cast<comparison_type>(this->_reference))); return abs_difference <= static_cast<comparison_type>(this->_tolerance); @@ -316,6 +323,13 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U toler } template <typename T, typename U> +void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number) +{ + // Validate with valid region covering the entire shape + validate_wrap(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number); +} + +template <typename T, typename U> void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) { int64_t num_mismatches = 0; @@ -376,6 +390,74 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const V } } +template <typename T, typename U> +void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) +{ + int64_t num_mismatches = 0; + int64_t num_elements = 0; + + ARM_COMPUTE_EXPECT_EQUAL(tensor.element_size(), reference.element_size(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(tensor.data_type(), reference.data_type(), framework::LogLevel::ERRORS); + + if(reference.format() != Format::UNKNOWN) + { + ARM_COMPUTE_EXPECT_EQUAL(tensor.format(), reference.format(), framework::LogLevel::ERRORS); + } + + ARM_COMPUTE_EXPECT_EQUAL(tensor.num_channels(), reference.num_channels(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(compare_dimensions(tensor.shape(), reference.shape()), framework::LogLevel::ERRORS); + + const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); + const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); + + // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... + for(int element_idx = 0; element_idx < min_elements; ++element_idx) + { + const Coordinates id = index2coord(reference.shape(), element_idx); + + if(is_in_valid_region(valid_region, id)) + { + // Iterate over all channels within one element + for(int c = 0; c < min_channels; ++c) + { + const T &target_value = reinterpret_cast<const T *>(tensor(id))[c]; + const T &reference_value = reinterpret_cast<const T *>(reference(id))[c]; + + bool equal = compare<U>(target_value, reference_value, tolerance_value); + + if(!equal) + { + equal = compare<U>(target_value, reference_value, tolerance_value, true); + } + + if(!equal) + { + ARM_COMPUTE_TEST_INFO("id = " << id); + ARM_COMPUTE_TEST_INFO("channel = " << c); + ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); + ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value)); + ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value))); + framework::ARM_COMPUTE_PRINT_INFO(); + + ++num_mismatches; + } + + ++num_elements; + } + } + } + + if(num_elements > 0) + { + const int64_t absolute_tolerance_number = tolerance_number * num_elements; + const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f; + + ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches + << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); + ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS); + } +} + /** Check which keypoints from [first1, last1) are missing in [first2, last2) */ template <typename T, typename U, typename V> std::pair<int64_t, int64_t> compare_keypoints(T first1, T last1, U first2, U last2, V tolerance) diff --git a/tests/validation/fixtures/FixedPointPixelWiseMultiplicationFixture.h b/tests/validation/fixtures/FixedPointPixelWiseMultiplicationFixture.h new file mode 100644 index 0000000000..d090d8583d --- /dev/null +++ b/tests/validation/fixtures/FixedPointPixelWiseMultiplicationFixture.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_FIXTURE +#define ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/FixedPointPixelWiseMultiplication.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class FixedPointPixelWiseMultiplicationValidationFixture : public framework::Fixture +{ +public: + template <typename...> + void setup(TensorShape shape, + DataType dt_in1, + DataType dt_in2, + float scale, + ConvertPolicy convert_policy, + RoundingPolicy rounding_policy, + int fixed_point_position) + { + _target = compute_target(shape, dt_in1, dt_in2, scale, convert_policy, rounding_policy, fixed_point_position); + _reference = compute_reference(shape, dt_in1, dt_in2, scale, convert_policy, fixed_point_position); + } + +protected: + template <typename U> + void fill(U &&tensor, unsigned int seed_offset) + { + library->fill_tensor_uniform(tensor, seed_offset); + } + + TensorType compute_target(const TensorShape &shape, DataType dt_in1, DataType dt_in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, int fixed_point_position) + { + // Create tensors + TensorType src1 = create_tensor<TensorType>(shape, dt_in1, 1, fixed_point_position); + TensorType src2 = create_tensor<TensorType>(shape, dt_in2, 1, fixed_point_position); + TensorType dst = create_tensor<TensorType>(shape, dt_in2, 1, fixed_point_position); + + // Create and configure function + FunctionType multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src1), 0); + fill(AccessorType(src2), 1); + + // Compute function + multiply.run(); + + return dst; + } + + SimpleTensor<T> compute_reference(const TensorShape &shape, DataType dt_in1, DataType dt_in2, float scale, ConvertPolicy convert_policy, int fixed_point_position) + { + // Create reference + SimpleTensor<T> src1{ shape, dt_in1, 1, fixed_point_position }; + SimpleTensor<T> src2{ shape, dt_in2, 1, fixed_point_position }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::fixed_point_pixel_wise_multiplication<T>(src1, src2, scale, convert_policy); + } + + TensorType _target{}; + SimpleTensor<T> _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FIXED_POINT_PIXEL_WISE_MULTIPLICATION_FIXTURE */ diff --git a/tests/validation/fixtures/PixelWiseMultiplicationFixture.h b/tests/validation/fixtures/PixelWiseMultiplicationFixture.h new file mode 100644 index 0000000000..351349e64e --- /dev/null +++ b/tests/validation/fixtures/PixelWiseMultiplicationFixture.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_FIXTURE +#define ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/PixelWiseMultiplication.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template <typename TensorType, typename AccessorType, typename FunctionType, typename T1, typename T2> +class PixelWiseMultiplicationValidationFixture : public framework::Fixture +{ +public: + template <typename...> + void setup(TensorShape shape, + DataType dt_in1, + DataType dt_in2, + float scale, + ConvertPolicy convert_policy, + RoundingPolicy rounding_policy) + { + _target = compute_target(shape, dt_in1, dt_in2, scale, convert_policy, rounding_policy); + _reference = compute_reference(shape, dt_in1, dt_in2, scale, convert_policy, rounding_policy); + } + +protected: + template <typename U> + void fill(U &&tensor, unsigned int seed_offset) + { + library->fill_tensor_uniform(tensor, seed_offset); + } + + TensorType compute_target(const TensorShape &shape, DataType dt_in1, DataType dt_in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) + { + // Create tensors + TensorType src1 = create_tensor<TensorType>(shape, dt_in1); + TensorType src2 = create_tensor<TensorType>(shape, dt_in2); + TensorType dst = create_tensor<TensorType>(shape, dt_in2); + + // Create and configure function + FunctionType multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src1), 0); + fill(AccessorType(src2), 1); + + // Compute function + multiply.run(); + + return dst; + } + + SimpleTensor<T2> compute_reference(const TensorShape &shape, DataType dt_in1, DataType dt_in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) + { + // Create reference + SimpleTensor<T1> src1{ shape, dt_in1 }; + SimpleTensor<T2> src2{ shape, dt_in2 }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::pixel_wise_multiplication<T1, T2>(src1, src2, scale, convert_policy, rounding_policy); + } + + TensorType _target{}; + SimpleTensor<T2> _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_PIXEL_WISE_MULTIPLICATION_FIXTURE */ diff --git a/tests/validation_old/CL/PixelWiseMultiplication.cpp b/tests/validation_old/CL/PixelWiseMultiplication.cpp deleted file mode 100644 index 5bc71820d0..0000000000 --- a/tests/validation_old/CL/PixelWiseMultiplication.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CL/CLAccessor.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/runtime/CL/functions/CLPixelWiseMultiplication.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_f32 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ -const float tolerance_f16 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ - -/** Compute CL pixel-wise multiplication function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. - * - * @return Computed output tensor. - */ -CLTensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, - int fixed_point_position = 0) -{ - // Create tensors - CLTensor src1 = create_tensor<CLTensor>(shape, dt_in0, 1, fixed_point_position); - CLTensor src2 = create_tensor<CLTensor>(shape, dt_in1, 1, fixed_point_position); - CLTensor dst = create_tensor<CLTensor>(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - CLPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src1), 0); - library->fill_tensor_uniform(CLAccessor(src2), 1); - - // Compute function - multiply.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) - -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F16 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, dt, convert_policy, rounding_policy) -{ - constexpr float scale = 1.f / 255.f; - - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f16); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F32 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, dt, convert_policy, rounding_policy) -{ - constexpr float scale = 1.f / 255.f; - - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f32); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif // DOXYGEN_SKIP_THIS diff --git a/tests/validation_old/NEON/PixelWiseMultiplication.cpp b/tests/validation_old/NEON/PixelWiseMultiplication.cpp deleted file mode 100644 index f352fc4390..0000000000 --- a/tests/validation_old/NEON/PixelWiseMultiplication.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon pixel-wise multiplication function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. - * - * @return Computed output tensor. - */ -Tensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, - int fixed_point_position = 0) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, dt_in0, 1, fixed_point_position); - Tensor src2 = create_tensor<Tensor>(shape, dt_in1, 1, fixed_point_position); - Tensor dst = create_tensor<Tensor>(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - NEPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - multiply.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, DataType::U8); - Tensor src2 = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, DataType::U8); - Tensor src2 = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, dt); - Tensor src2 = create_tensor<Tensor>(shape, DataType::S16); - Tensor dst = create_tensor<Tensor>(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, - scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, dt); - Tensor src2 = create_tensor<Tensor>(shape, DataType::S16); - Tensor dst = create_tensor<Tensor>(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, - scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(F16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) - -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max()); -} - -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(F32) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, DataType::F32); - Tensor src2 = create_tensor<Tensor>(shape, DataType::F32); - Tensor dst = create_tensor<Tensor>(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, - scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(shape, DataType::F32); - Tensor src2 = create_tensor<Tensor>(shape, DataType::F32); - Tensor dst = create_tensor<Tensor>(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, - scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 7), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast<float>(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLargeScale255, LargeShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLargeScaleOther, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast<float>(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS16 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 15), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast<float>(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Reference.cpp b/tests/validation_old/Reference.cpp index 628bd11f4b..c76d429067 100644 --- a/tests/validation_old/Reference.cpp +++ b/tests/validation_old/Reference.cpp @@ -128,42 +128,6 @@ RawTensor Reference::compute_reference_accumulate_weighted(const TensorShape &sh return ref_dst; } -RawTensor Reference::compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, - RoundingPolicy rounding_policy) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0); - RawTensor ref_src2(shape, dt_in1); - RawTensor ref_dst(shape, dt_out); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); - - return ref_dst; -} - -RawTensor Reference::compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, - ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); - RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::fixed_point_pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); - - return ref_dst; -} - RawTensor Reference::compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector<ROI> &rois, const ROIPoolingLayerInfo &pool_info) { TensorShape shape_dst; diff --git a/tests/validation_old/Reference.h b/tests/validation_old/Reference.h index f6235f5309..7b4043c466 100644 --- a/tests/validation_old/Reference.h +++ b/tests/validation_old/Reference.h @@ -89,35 +89,6 @@ public: * @return Computed raw tensor. */ static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); - /** Compute reference pixel-wise multiplication - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, - RoundingPolicy rounding_policy); - /** Compute reference pixel-wise multiplication. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Scale to apply after multiplication. Must be positive. - * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, - ConvertPolicy convert_policy, RoundingPolicy rounding_policy); /** Compute reference roi pooling layer. * * @param[in] shape Shape of the input tensor. diff --git a/tests/validation_old/ReferenceCPP.cpp b/tests/validation_old/ReferenceCPP.cpp index fc274f5c4b..4d6141a383 100644 --- a/tests/validation_old/ReferenceCPP.cpp +++ b/tests/validation_old/ReferenceCPP.cpp @@ -130,24 +130,6 @@ void ReferenceCPP::non_linear_filter(const RawTensor &src, RawTensor &dst, NonLi tensor_operations::non_linear_filter(s, d, function, mask_size, pattern, mask, border_mode, constant_border_value); } -// Pixel-wise multiplication -void ReferenceCPP::pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(pixel_wise_multiplication_visitor(scale, convert_policy, rounding_policy), s1, s2, d); -} - -// Fixed-point Pixel-wise multiplication -void ReferenceCPP::fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::fixed_point_pixel_wise_multiplication_visitor(s1, s2, scale, convert_policy, rounding_policy), d); -} - // Threshold void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) { diff --git a/tests/validation_old/ReferenceCPP.h b/tests/validation_old/ReferenceCPP.h index 6bc44b32b4..79d0d698d6 100644 --- a/tests/validation_old/ReferenceCPP.h +++ b/tests/validation_old/ReferenceCPP.h @@ -109,26 +109,6 @@ public: */ static void non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); - /** Element-wise multiplication of @p src1, @p src2 and @p scale - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] scale A non-negative float multiplied to each product. - * @param[in] convert_policy Overflow policy. - * @param[in] rounding_policy Rounding policy. - */ - static void pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Fixed-point Pixel-wise multiplication of @p src1 by @p src2 - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] scale A non-negative float multiplied to each product. - * @param[in] convert_policy Overflow policy. - * @param[in] rounding_policy Rounding policy. - */ - static void fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); /** Threshold of@p src to @p dst * * @param[in] src Input tensor. diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h index 2b326930f6..e03336505b 100644 --- a/tests/validation_old/TensorOperations.h +++ b/tests/validation_old/TensorOperations.h @@ -528,80 +528,6 @@ void non_linear_filter(const Tensor<T> &in, Tensor<T> &out, NonLinearFilterFunct } } -// Pixel-wise multiplication -template <typename T1, typename T2, typename T3> -void pixel_wise_multiplication(const Tensor<T1> &in1, const Tensor<T2> &in2, Tensor<T3> &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - if(scale < 0) - { - ARM_COMPUTE_ERROR("Scale of pixel-wise multiplication must be non-negative"); - } - using intermediate_type = typename common_promoted_signed_type<T1, T2, T3>::intermediate_type; - for(int i = 0; i < in1.num_elements(); ++i) - { - double val = static_cast<intermediate_type>(in1[i]) * static_cast<intermediate_type>(in2[i]) * static_cast<double>(scale); - if(is_floating_point<T3>::value) - { - out[i] = val; - } - else - { - double rounded_val = 0; - switch(rounding_policy) - { - case(RoundingPolicy::TO_ZERO): - rounded_val = support::cpp11::trunc(val); - break; - case(RoundingPolicy::TO_NEAREST_UP): - rounded_val = round_half_up(val); - break; - case(RoundingPolicy::TO_NEAREST_EVEN): - rounded_val = round_half_even(val); - break; - default: - ARM_COMPUTE_ERROR("Unsupported rounding policy"); - } - out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast<T3>(rounded_val) : static_cast<T3>(rounded_val); - } - } -} - -// Fixed-point Pixel-wise Multiplication -template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> -void fixed_point_pixel_wise_multiplication(const Tensor<T> &in1, const Tensor<T> &in2, Tensor<T> &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = in1.fixed_point_position(); - - ARM_COMPUTE_ERROR_ON_MSG(in1.data_type() != in2.data_type() || in1.data_type() != out.data_type(), - "Tensors must all have the same DataType"); - ARM_COMPUTE_ERROR_ON_MSG(fixed_point_position != in2.fixed_point_position() || fixed_point_position != out.fixed_point_position(), - "Fixed-point position must be the same for both inputs and outputs"); - - // Validate fixed_point_position - ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS8) && (fixed_point_position == 0 || fixed_point_position > 7)); - ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS16) && (fixed_point_position == 0 || fixed_point_position > 15)); - - const fixed_point<T> fp_scale(scale, fixed_point_position); - const bool is_sat = convert_policy == ConvertPolicy::SATURATE; - - for(int i = 0; i < in1.num_elements(); ++i) - { - const fixed_point<T> val1(in1[i], fixed_point_position, true); - fixed_point<T> res(in2[i], fixed_point_position, true); - if(is_sat) - { - res = mul(mul(res, val1), fp_scale); - } - else - { - res = mul<OverflowPolicy::WRAP>(mul<OverflowPolicy::WRAP>(res, val1), fp_scale); - } - out[i] = res.raw(); - } -} - // Threshold template <typename T> void threshold(const Tensor<T> &in, Tensor<T> &out, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) diff --git a/tests/validation_old/TensorVisitors.h b/tests/validation_old/TensorVisitors.h index 30b552ae3c..72c2ba06a7 100644 --- a/tests/validation_old/TensorVisitors.h +++ b/tests/validation_old/TensorVisitors.h @@ -56,55 +56,6 @@ public: tensor_operations::absolute_difference(in1, in2, out); } }; -// Pixel-wise Multiplication visitor -struct pixel_wise_multiplication_visitor : public boost::static_visitor<> -{ -public: - explicit pixel_wise_multiplication_visitor(float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) - : _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) - { - } - - template <typename T1, typename T2, typename T3> - void operator()(const Tensor<T1> &in1, const Tensor<T2> &in2, Tensor<T3> &out) const - { - tensor_operations::pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); - } - -private: - float _scale; - ConvertPolicy _convert_policy; - RoundingPolicy _rounding_policy; -}; -// Fixed Point Pixel-wise Multiplication visitor -struct fixed_point_pixel_wise_multiplication_visitor : public boost::static_visitor<> -{ -public: - explicit fixed_point_pixel_wise_multiplication_visitor(const TensorVariant &in1, const TensorVariant &in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) - : _in1(in1), _in2(in2), _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) - { - } - - template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> - void operator()(Tensor<T> &out) const - { - const Tensor<T> &in1 = boost::get<Tensor<T>>(_in1); - const Tensor<T> &in2 = boost::get<Tensor<T>>(_in2); - tensor_operations::fixed_point_pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); - } - template < typename T, typename std::enable_if < !std::is_integral<T>::value, int >::type = 0 > - void operator()(Tensor<T> &out) const - { - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - -private: - const TensorVariant &_in1; - const TensorVariant &_in2; - float _scale; - ConvertPolicy _convert_policy; - RoundingPolicy _rounding_policy; -}; // ROI Pooling layer struct roi_pooling_layer_visitor : public boost::static_visitor<> |