diff options
author | John Richardson <john.richardson@arm.com> | 2017-10-04 15:27:37 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 3c5f949ad73fff961a7d193c9275b73df13b8096 (patch) | |
tree | f7285b4223d2f40907ac5edb4d32bfe3c2883830 /tests | |
parent | 0063380ca6e43d04722707c707e610b59e1f8dde (diff) | |
download | ComputeLibrary-3c5f949ad73fff961a7d193c9275b73df13b8096.tar.gz |
COMPMID-575: Port Magnitude to new validation
Change-Id: I2600947bef30853d00adfa4b919dbcb860de9bfd
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/91717
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Utils.h | 14 | ||||
-rw-r--r-- | tests/validation/CL/Magnitude.cpp | 123 | ||||
-rw-r--r-- | tests/validation/CPP/Magnitude.cpp | 68 | ||||
-rw-r--r-- | tests/validation/CPP/Magnitude.h | 43 | ||||
-rw-r--r-- | tests/validation/NEON/Magnitude.cpp | 125 | ||||
-rw-r--r-- | tests/validation/fixtures/MagnitudeFixture.h | 123 |
6 files changed, 496 insertions, 0 deletions
diff --git a/tests/Utils.h b/tests/Utils.h index 4745b8bbd7..465cba88ab 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -106,6 +106,10 @@ using promote_t = typename promote<T>::type; template <typename T> using make_signed_conditional_t = typename std::conditional<std::is_integral<T>::value, std::make_signed<T>, std::common_type<T>>::type; + +template <typename T> +using make_unsigned_conditional_t = typename std::conditional<std::is_integral<T>::value, std::make_unsigned<T>, std::common_type<T>>::type; + // clang-format on // *INDENT-ON* } @@ -298,6 +302,16 @@ struct common_promoted_signed_type using intermediate_type = typename traits::make_signed_conditional_t<promoted_type>::type; }; +/** Find the unsigned promoted common type. + */ +template <typename... T> +struct common_promoted_unsigned_type +{ + using common_type = typename std::common_type<T...>::type; + using promoted_type = traits::promote_t<common_type>; + using intermediate_type = typename traits::make_unsigned_conditional_t<promoted_type>::type; +}; + /** Convert a linear index into n-dimensional coordinates. * * @param[in] shape Shape of the n-dimensional tensor. diff --git a/tests/validation/CL/Magnitude.cpp b/tests/validation/CL/Magnitude.cpp new file mode 100644 index 0000000000..b002239e01 --- /dev/null +++ b/tests/validation/CL/Magnitude.cpp @@ -0,0 +1,123 @@ +/* + * 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/CLMagnitude.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/MagnitudeFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +template <typename T> +AbsoluteTolerance<T> tolerance(MagnitudeType magnitude_type) +{ + return AbsoluteTolerance<T>((MagnitudeType::L1NORM == magnitude_type) ? 0 : 1); +} +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(Magnitude) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::S16, DataType::S32 })), + shape, data_type) +{ + // Create tensors + CLTensor src1 = create_tensor<CLTensor>(shape, data_type); + CLTensor src2 = create_tensor<CLTensor>(shape, data_type); + CLTensor dst = create_tensor<CLTensor>(shape, data_type); + + 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 (default MagnitudeType::L2NORM) + CLMagnitude magnitude; + magnitude.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + 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); +} + +template <typename T> +using CLMagnitudeFixture = MagnitudeValidationFixture<CLTensor, CLAccessor, CLMagnitude, T>; + +TEST_SUITE(S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLMagnitudeFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), framework::dataset::make("Format", Format::S16)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance<int16_t>(_magnitude_type)); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLMagnitudeFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), framework::dataset::make("Format", Format::S16)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance<int16_t>(_magnitude_type)); +} +TEST_SUITE_END() // S16 + +TEST_SUITE(S32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLMagnitudeFixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), framework::dataset::make("Format", Format::S32)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance<int32_t>(_magnitude_type)); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLMagnitudeFixture<int32_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), framework::dataset::make("Format", Format::S32)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance<int32_t>(_magnitude_type)); +} +TEST_SUITE_END() // S32 + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Magnitude.cpp b/tests/validation/CPP/Magnitude.cpp new file mode 100644 index 0000000000..f0002bfb33 --- /dev/null +++ b/tests/validation/CPP/Magnitude.cpp @@ -0,0 +1,68 @@ +/* + * 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 "Magnitude.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <typename T> +SimpleTensor<T> magnitude(const SimpleTensor<T> &gx, const SimpleTensor<T> &gy, MagnitudeType magnitude_type) +{ + SimpleTensor<T> mag(gx.shape(), gx.data_type()); + + using intermediate_type = typename common_promoted_unsigned_type<T>::intermediate_type; + + for(int i = 0; i < gx.num_elements(); ++i) + { + double val = 0.f; + + if(magnitude_type == MagnitudeType::L1NORM) + { + val = static_cast<intermediate_type>(std::abs(gx[i])) + static_cast<intermediate_type>(std::abs(gy[i])); + } + else // MagnitudeType::L2NORM + { + // Note: kernel saturates to uint32_t instead of intermediate_type for S32 format + auto sum = static_cast<uint32_t>(gx[i] * gx[i]) + static_cast<uint32_t>(gy[i] * gy[i]); + val = std::sqrt(sum) + 0.5f; + } + + mag[i] = saturate_cast<T>(val); + } + + return mag; +} + +template SimpleTensor<int16_t> magnitude(const SimpleTensor<int16_t> &gx, const SimpleTensor<int16_t> &gy, MagnitudeType magnitude_type); +template SimpleTensor<int32_t> magnitude(const SimpleTensor<int32_t> &gx, const SimpleTensor<int32_t> &gy, MagnitudeType magnitude_type); +template SimpleTensor<half_float::half> magnitude(const SimpleTensor<half_float::half> &gx, const SimpleTensor<half_float::half> &gy, MagnitudeType magnitude_type); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Magnitude.h b/tests/validation/CPP/Magnitude.h new file mode 100644 index 0000000000..75620712e3 --- /dev/null +++ b/tests/validation/CPP/Magnitude.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_MAGNITUDE_H__ +#define __ARM_COMPUTE_TEST_MAGNITUDE_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template <typename T> +SimpleTensor<T> magnitude(const SimpleTensor<T> &gx, const SimpleTensor<T> &gy, MagnitudeType magnitude_type); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_MAGNITUDE_H__ */ diff --git a/tests/validation/NEON/Magnitude.cpp b/tests/validation/NEON/Magnitude.cpp new file mode 100644 index 0000000000..cdc29a58dc --- /dev/null +++ b/tests/validation/NEON/Magnitude.cpp @@ -0,0 +1,125 @@ +/* + * 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/NEMagnitude.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/MagnitudeFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +template <typename T> +AbsoluteTolerance<T> tolerance(MagnitudeType magnitude_type) +{ + return AbsoluteTolerance<T>((MagnitudeType::L1NORM == magnitude_type) ? 0 : 1); +} + +#ifdef ARM_COMPUTE_AARCH64_V8_2 +template <> +AbsoluteTolerance<half_float::half> tolerance(MagnitudeType magnitude_type) +{ + return AbsoluteTolerance<half_float::half>((MagnitudeType::L1NORM == magnitude_type) ? half(0.0) : half(1.0)); +} +#endif /* ARM_COMPUTE_AARCH64_V8_2 */ + +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(Magnitude) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::S16)), shape, data_type) +{ + // Create tensors + Tensor src1 = create_tensor<Tensor>(shape, data_type); + Tensor src2 = create_tensor<Tensor>(shape, data_type); + Tensor dst = create_tensor<Tensor>(shape, data_type); + + 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 (default MagnitudeType::L2NORM) + NEMagnitude magnitude; + magnitude.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + 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); +} + +template <typename T> +using NEMagnitudeFixture = MagnitudeValidationFixture<Tensor, Accessor, NEMagnitude, T>; + +TEST_SUITE(S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEMagnitudeFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), framework::dataset::make("Format", Format::S16)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance<int16_t>(_magnitude_type)); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEMagnitudeFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), framework::dataset::make("Format", Format::S16)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", false))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance<int16_t>(_magnitude_type)); +} +TEST_SUITE_END() // S16 + +#ifdef ARM_COMPUTE_AARCH64_V8_2 +TEST_SUITE(F16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEMagnitudeFixture<half_float::half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), framework::dataset::make("Format", + Format::S16)), + framework::dataset::make("MagnitudeType", { MagnitudeType::L1NORM, MagnitudeType::L2NORM })), + framework::dataset::make("UseFP16", true))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance<half_float::half>(_magnitude_type)); +} +TEST_SUITE_END() // F16 +#endif /* ARM_COMPUTE_AARCH64_V8_2 */ + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/fixtures/MagnitudeFixture.h b/tests/validation/fixtures/MagnitudeFixture.h new file mode 100644 index 0000000000..dcd3da8dfe --- /dev/null +++ b/tests/validation/fixtures/MagnitudeFixture.h @@ -0,0 +1,123 @@ +/* + * 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_MAGNITUDE_FIXTURE +#define ARM_COMPUTE_TEST_MAGNITUDE_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/Magnitude.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template <typename TensorType, typename AccessorType, typename FunctionType, typename T> +class MagnitudeValidationFixture : public framework::Fixture +{ +public: + template <typename...> + void setup(TensorShape shape, Format format, MagnitudeType magnitude_type, bool use_fp16) + { + _target = compute_target(shape, format, magnitude_type, use_fp16); + _reference = compute_reference(shape, format, magnitude_type); + _magnitude_type = magnitude_type; + } + +protected: + template <typename U> + void fill(U &&tensor, std::random_device::result_type seed_offset) + { + library->fill_tensor_uniform(tensor, seed_offset); + } + + TensorType compute_target(const TensorShape &shape, Format format, MagnitudeType magnitude_type, bool use_fp16) + { + DataType data_type = data_type_from_format(format); + + // Create tensors + TensorType src1 = create_tensor<TensorType>(shape, data_type); + src1.info()->set_format(format); + + TensorType src2 = create_tensor<TensorType>(shape, data_type); + src2.info()->set_format(format); + + TensorType dst = create_tensor<TensorType>(shape, data_type); + dst.info()->set_format(format); + + // Create and configure function + FunctionType magnitude; + magnitude.configure(&src1, &src2, &dst, magnitude_type, use_fp16); + + 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 + magnitude.run(); + + return dst; + } + + SimpleTensor<T> compute_reference(const TensorShape &shape, Format format, MagnitudeType magnitude_type) + { + DataType data_type = data_type_from_format(format); + + // Create reference + SimpleTensor<T> src1{ shape, data_type }; + SimpleTensor<T> src2{ shape, data_type }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::magnitude<T>(src1, src2, magnitude_type); + } + + TensorType _target{}; + SimpleTensor<T> _reference{}; + MagnitudeType _magnitude_type{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MAGNITUDE_FIXTURE */ |