chromium/third_party/tflite/src/tensorflow/lite/kernels/rfft2d.cc

/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <algorithm>
#include <complex>

#include "third_party/fft2d/fft2d.h"
#include "ruy/profiler/instrumentation.h"  // from @ruy
#include "tensorflow/lite/core/c/common.h"
#include "tensorflow/lite/kernels/internal/tensor.h"
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
#include "tensorflow/lite/kernels/internal/types.h"
#include "tensorflow/lite/kernels/kernel_util.h"

namespace tflite {
namespace ops {
namespace builtin {
namespace rfft2d {

complex;

constexpr int kInputTensor =;
constexpr int kFftLengthTensor =;
constexpr int kOutputTensor =;
constexpr int kFftIntegerWorkingAreaTensor =;
constexpr int kFftDoubleWorkingAreaTensor =;
constexpr int kTensorNotAllocated =;

struct OpData {};

bool IsPowerOfTwo(uint32_t v) {}

static TfLiteStatus InitTemporaryTensors(TfLiteContext* context,
                                         TfLiteNode* node) {}

TfLiteStatus ResizeOutputandTemporaryTensors(TfLiteContext* context,
                                             TfLiteNode* node) {}

void* Init(TfLiteContext* context, const char* buffer, size_t length) {}

void Free(TfLiteContext* context, void* buffer) {}

TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {}

// Reorder the result so that it matches the pattern of tf.signal.rfft2d.
// In tf.signal.fft2d the frequency matrix of a 4x4 input is
//    [[F(0, 0),  F(0, 1/4),   F(0, 2/4)],
//    [F(1/4, 0), F(1/4, 1/4), F(1/4, 2/4)],
//    [F(2/4, 0), F(2/4, 1/4), F(2/4, 2/4)],
//    [F(3/4, 0), F(3/4, 1/4), F(3/4, 2/4)]]
// While in rdft2d, the frequency matrix of a 4x4 input is
//    [[(F(0, 0), F(0, -2/4))       F(0, -1/4),   0],
//     [ F(-1/4, 0),                F(-1/4, -1/4), 0],
//     [(F(-2/4, 0),F(-2/4, -2/4)), F(-2/4, -1/4), 0],
//     [ j*F(-3/4, -2/4),           F(-3/4, -1/4), 0]]
// Since real fft has the property that
//   Real(u,v) = Real(-u, -v)
//   Img(u,v) = - Img(-u, -v)
// Result of rdft2d can be reordered and match the pattern of tf.signal.rfft2d.
// For example,
//   Real(-3/4, 0) = Real(1/4, 0) = Real(-1/4, 0)
//   Img(-3/4, 0) = Img(1/4, 0) = -Img(-1/4, 0)
void Rfft2dReorder(int fft_height, int fft_width, double** fft_input_output) {}

void Rfft2dImpl(int fft_height, int fft_width, double** fft_input_output,
                int* fft_integer_working_area_data,
                double* fft_double_working_area_data) {}

void PrepareInputBuffer(const float* input_data, int input_height,
                        int input_width, int fft_height, int fft_width,
                        double** fft_input_output) {}

void PrepareOutputBuffer(complex<float>* output_data, int fft_height,
                         int fft_width, double** fft_input_output) {}

TfLiteStatus Rfft2dHelper(TfLiteContext* context, TfLiteNode* node) {}

TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {}

}  // namespace rfft2d

TfLiteRegistration* Register_RFFT2D() {}

}  // namespace builtin
}  // namespace ops
}  // namespace tflite