| 52 | } |
| 53 | |
| 54 | void NEFFT1D::configure(const ITensor *input, ITensor *output, const FFT1DInfo &config) |
| 55 | { |
| 56 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "NEFFT1D::configure"); |
| 57 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 58 | ARM_COMPUTE_ERROR_THROW_ON(NEFFT1D::validate(input->info(), output->info(), config)); |
| 59 | ARM_COMPUTE_LOG_PARAMS(input, output, config); |
| 60 | |
| 61 | // Decompose size to radix factors |
| 62 | const auto supported_radix = NEFFTRadixStageKernel::supported_radix(); |
| 63 | const unsigned int N = input->info()->tensor_shape()[config.axis]; |
| 64 | const auto decomposed_vector = arm_compute::helpers::fft::decompose_stages(N, supported_radix); |
| 65 | ARM_COMPUTE_ERROR_ON(decomposed_vector.empty()); |
| 66 | |
| 67 | // Flags |
| 68 | _run_scale = config.direction == FFTDirection::Inverse; |
| 69 | |
| 70 | const bool is_c2r = input->info()->num_channels() == 2 && output->info()->num_channels() == 1; |
| 71 | |
| 72 | // Configure digit reverse |
| 73 | FFTDigitReverseKernelInfo digit_reverse_config; |
| 74 | digit_reverse_config.axis = config.axis; |
| 75 | digit_reverse_config.conjugate = config.direction == FFTDirection::Inverse; |
| 76 | TensorInfo digit_reverse_indices_info(TensorShape(input->info()->tensor_shape()[config.axis]), 1, DataType::U32); |
| 77 | _digit_reverse_indices.allocator()->init(digit_reverse_indices_info); |
| 78 | _memory_group.manage(&_digit_reversed_input); |
| 79 | _digit_reverse_kernel = std::make_unique<NEFFTDigitReverseKernel>(); |
| 80 | _digit_reverse_kernel->configure(input, &_digit_reversed_input, &_digit_reverse_indices, digit_reverse_config); |
| 81 | |
| 82 | // Create and configure FFT kernels |
| 83 | unsigned int Nx = 1; |
| 84 | _num_ffts = decomposed_vector.size(); |
| 85 | _fft_kernels.resize(_num_ffts); |
| 86 | _axis = config.axis; |
| 87 | |
| 88 | for (unsigned int i = 0; i < _num_ffts; ++i) |
| 89 | { |
| 90 | const unsigned int radix_for_stage = decomposed_vector.at(i); |
| 91 | |
| 92 | FFTRadixStageKernelInfo fft_kernel_info; |
| 93 | fft_kernel_info.axis = config.axis; |
| 94 | fft_kernel_info.radix = radix_for_stage; |
| 95 | fft_kernel_info.Nx = Nx; |
| 96 | fft_kernel_info.is_first_stage = (i == 0); |
| 97 | _fft_kernels[i] = std::make_unique<NEFFTRadixStageKernel>(); |
| 98 | _fft_kernels[i]->configure(&_digit_reversed_input, ((i == (_num_ffts - 1)) && !is_c2r) ? output : nullptr, |
| 99 | fft_kernel_info); |
| 100 | |
| 101 | Nx *= radix_for_stage; |
| 102 | } |
| 103 | |
| 104 | // Configure scale kernel |
| 105 | if (_run_scale) |
| 106 | { |
| 107 | FFTScaleKernelInfo scale_config; |
| 108 | scale_config.scale = static_cast<float>(N); |
| 109 | scale_config.conjugate = config.direction == FFTDirection::Inverse; |
| 110 | _scale_kernel = std::make_unique<NEFFTScaleKernel>(); |
| 111 | is_c2r ? _scale_kernel->configure(&_digit_reversed_input, output, scale_config) |
nothing calls this directly
no test coverage detected