aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorgiuros01 <giuseppe.rossini@arm.com>2019-03-26 17:44:40 +0000
committerGiuseppe Rossini <giuseppe.rossini@arm.com>2019-04-26 15:16:46 +0000
commit14c4e0f1c3e3bfebb33eb1ceb8156b3a090f4d11 (patch)
treeb28e4be597f8dcd1fed4408cebb130af49272390 /arm_compute
parent098516b74a0948707119c64c641a0a8fdf529454 (diff)
downloadComputeLibrary-14c4e0f1c3e3bfebb33eb1ceb8156b3a090f4d11.tar.gz
COMPMID-1961: Implement FFT (1D) on NEON
Change-Id: I0bea3bfbc3b0cd9e8c9a0e0f6f430640573f08d1 Signed-off-by: giuros01 <giuseppe.rossini@arm.com> Reviewed-on: https://review.mlplatform.org/c/996 Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/NEON/NEKernels.h2
-rw-r--r--arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h83
-rw-r--r--arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h98
-rw-r--r--arm_compute/runtime/NEON/NEFunctions.h1
-rw-r--r--arm_compute/runtime/NEON/functions/NEFFT1D.h79
5 files changed, 263 insertions, 0 deletions
diff --git a/arm_compute/core/NEON/NEKernels.h b/arm_compute/core/NEON/NEKernels.h
index 1ce3821e81..b8ae467c6d 100644
--- a/arm_compute/core/NEON/NEKernels.h
+++ b/arm_compute/core/NEON/NEKernels.h
@@ -62,6 +62,8 @@
#include "arm_compute/core/NEON/kernels/NEElementwiseOperationKernel.h"
#include "arm_compute/core/NEON/kernels/NEElementwiseUnaryKernel.h"
#include "arm_compute/core/NEON/kernels/NEErodeKernel.h"
+#include "arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h"
+#include "arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h"
#include "arm_compute/core/NEON/kernels/NEFastCornersKernel.h"
#include "arm_compute/core/NEON/kernels/NEFillArrayKernel.h"
#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
diff --git a/arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h b/arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h
new file mode 100644
index 0000000000..84d55fd8f4
--- /dev/null
+++ b/arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2019 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_NEFFTDIGITREVERSEKERNEL_H__
+#define __ARM_COMPUTE_NEFFTDIGITREVERSEKERNEL_H__
+
+#include "arm_compute/core/NEON/INEKernel.h"
+
+namespace arm_compute
+{
+// Forward declarations
+class ITensor;
+
+/** Interface for the digit reverse operation kernel. */
+class NEFFTDigitReverseKernel : public INEKernel
+{
+public:
+ const char *name() const override
+ {
+ return "NEFFTDigitReverseKernel";
+ }
+ /** Constructor */
+ NEFFTDigitReverseKernel();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEFFTDigitReverseKernel(const NEFFTDigitReverseKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEFFTDigitReverseKernel &operator=(const NEFFTDigitReverseKernel &) = delete;
+ /** Default Move Constructor. */
+ NEFFTDigitReverseKernel(NEFFTDigitReverseKernel &&) = default;
+ /** Default move assignment operator */
+ NEFFTDigitReverseKernel &operator=(NEFFTDigitReverseKernel &&) = default;
+ /** Default destructor */
+ ~NEFFTDigitReverseKernel() = default;
+ /** Set the input and output tensors.
+ *
+ * @param[in] input Source tensor. Data types supported: F32.
+ * @param[out] output Destination tensor. Data type supported: same as @p input
+ * @param[in] idx Digit reverse index tensor. Data type supported: U32
+ * @param[in] axis Axis to perform digit reverse on.
+ */
+ void configure(const ITensor *input, ITensor *output, const ITensor *idx, unsigned int axis);
+ /** Static function to check if given info will lead to a valid configuration of @ref NEFFTDigitReverseKernel
+ *
+ * @param[in] input Source tensor info. Data types supported: F32.
+ * @param[in] output Destination tensor info. Data type supported: same as @p input
+ * @param[in] idx Digit reverse index tensor info. Data type supported: U32
+ * @param[in] axis Axis to perform digit reverse on.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *idx, unsigned int axis);
+
+ // Inherited methods overridden:
+ void run(const Window &window, const ThreadInfo &info) override;
+
+private:
+ const ITensor *_input;
+ ITensor *_output;
+ const ITensor *_idx;
+ unsigned int _axis;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_NEFFTDIGITREVERSEKERNEL_H__ */
diff --git a/arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h b/arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h
new file mode 100644
index 0000000000..a4c4be6f35
--- /dev/null
+++ b/arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019 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_NEFFTRADIXSTAGEKERNEL_H__
+#define __ARM_COMPUTE_NEFFTRADIXSTAGEKERNEL_H__
+
+#include "arm_compute/core/NEON/INEKernel.h"
+
+#include "arm_compute/core/KernelDescriptors.h"
+
+#include <set>
+
+namespace arm_compute
+{
+// Forward declarations
+class ITensor;
+
+/** Interface for the FFT kernel. */
+class NEFFTRadixStageKernel : public INEKernel
+{
+public:
+ const char *name() const override
+ {
+ return "NEFFTRadixStageKernel";
+ }
+ /** Constructor */
+ NEFFTRadixStageKernel();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEFFTRadixStageKernel(const NEFFTRadixStageKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ NEFFTRadixStageKernel &operator=(const NEFFTRadixStageKernel &) = delete;
+ /** Default Move Constructor. */
+ NEFFTRadixStageKernel(NEFFTRadixStageKernel &&) = default;
+ /** Default move assignment operator */
+ NEFFTRadixStageKernel &operator=(NEFFTRadixStageKernel &&) = default;
+ /** Default destructor */
+ ~NEFFTRadixStageKernel() = default;
+ /** Set the input and output tensors.
+ *
+ * @note If the output tensor is nullptr, the FFT will be performed in-place
+ *
+ * @param[in,out] input Source tensor. Data types supported: F32.
+ * @param[out] output Destination tensor. Data type supported: same as @p input
+ * @param[in] config FFT descriptor metadata.
+ */
+ void configure(ITensor *input, ITensor *output, const FFTRadixStageKernelInfo &config);
+ /** Static function to check if given info will lead to a valid configuration of @ref NEFFTRadixStageKernel
+ *
+ * @param[in] input Source tensor info. Data types supported: F32.
+ * @param[in] output Destination tensor info. Data type supported: same as @p input
+ * @param[in] config FFT descriptor metadata.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const FFTRadixStageKernelInfo &config);
+ /** Returns the radix that are support by the FFT kernel
+ *
+ * @return A set of supported radix
+ */
+ static std::set<unsigned int> supported_radix();
+
+ // Inherited methods overridden:
+ void run(const Window &window, const ThreadInfo &info) override;
+
+private:
+ ITensor *_input;
+ ITensor *_output;
+ bool _run_in_place;
+ unsigned int _Nx;
+
+ template <bool first_stage>
+ void set_radix_stage_fun(unsigned int radix);
+
+ using FFTFunctionPointerInPlace = std::function<void(float *, float *, unsigned int, unsigned int)>;
+ FFTFunctionPointerInPlace _func;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_NEFFTKERNEL_H__ */
diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h
index 432c751308..d8f54ea231 100644
--- a/arm_compute/runtime/NEON/NEFunctions.h
+++ b/arm_compute/runtime/NEON/NEFunctions.h
@@ -63,6 +63,7 @@
#include "arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h"
#include "arm_compute/runtime/NEON/functions/NEEqualizeHistogram.h"
#include "arm_compute/runtime/NEON/functions/NEErode.h"
+#include "arm_compute/runtime/NEON/functions/NEFFT1D.h"
#include "arm_compute/runtime/NEON/functions/NEFastCorners.h"
#include "arm_compute/runtime/NEON/functions/NEFillBorder.h"
#include "arm_compute/runtime/NEON/functions/NEFlattenLayer.h"
diff --git a/arm_compute/runtime/NEON/functions/NEFFT1D.h b/arm_compute/runtime/NEON/functions/NEFFT1D.h
new file mode 100644
index 0000000000..9b5ada746a
--- /dev/null
+++ b/arm_compute/runtime/NEON/functions/NEFFT1D.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019 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_NEFFT1D_H__
+#define __ARM_COMPUTE_NEFFT1D_H__
+
+#include "arm_compute/core/NEON/kernels/NEFFTDigitReverseKernel.h"
+#include "arm_compute/core/NEON/kernels/NEFFTRadixStageKernel.h"
+#include "arm_compute/runtime/IFunction.h"
+
+#include "arm_compute/runtime/FunctionDescriptors.h"
+#include "arm_compute/runtime/MemoryGroup.h"
+#include "arm_compute/runtime/Tensor.h"
+
+namespace arm_compute
+{
+// Forward declaration
+class ITensor;
+
+/** Basic function to execute one dimensional FFT. This function calls the following OpenCL kernels:
+ *
+ * -# @ref CLFFTDigitReverseKernel Performs digit reverse
+ * -# @ref NEFFTRadixStageKernel A list of FFT kernels depending on the radix decomposition
+ */
+class NEFFT1D : public IFunction
+{
+public:
+ /** Default Constructor */
+ NEFFT1D(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
+ /** Initialise the function's source, destinations and border mode.
+ *
+ * @param[in] input Source tensor. Data types supported: F32.
+ * @param[out] output Destination tensor. Data types and data layouts supported: Same as @p input.
+ * @param[in] config FFT related configuration
+ */
+ void configure(const ITensor *input, ITensor *output, const FFT1DInfo &config);
+ /** Static function to check if given info will lead to a valid configuration of @ref CLFFT1D.
+ *
+ * @param[in] input Source tensor info. Data types supported: F32.
+ * @param[in] output Destination tensor info. Data types and data layouts supported: Same as @p input.
+ * @param[in] config FFT related configuration
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const FFT1DInfo &config);
+
+ // Inherited methods overridden:
+ void run() override;
+
+protected:
+ MemoryGroup _memory_group;
+ Tensor _digit_reversed_input;
+ Tensor _digit_reverse_indices;
+ NEFFTDigitReverseKernel _digit_reverse_kernel;
+ std::vector<NEFFTRadixStageKernel> _fft_kernels;
+ unsigned int _n_ffts;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_NEFFT1D_H__ */