1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #include "tensorflow/lite/experimental/microfrontend/lib/fft_io.h"
16
FftWriteMemmapPreamble(FILE * fp,const struct FftState * state)17 void FftWriteMemmapPreamble(FILE* fp, const struct FftState* state) {
18 fprintf(fp, "static int16_t fft_input[%zu];\n", state->fft_size);
19 fprintf(fp, "static struct complex_int16_t fft_output[%zu];\n",
20 state->fft_size / 2 + 1);
21 fprintf(fp, "static char fft_scratch[%zu];\n", state->scratch_size);
22 fprintf(fp, "\n");
23 }
24
FftWriteMemmap(FILE * fp,const struct FftState * state,const char * variable)25 void FftWriteMemmap(FILE* fp, const struct FftState* state,
26 const char* variable) {
27 fprintf(fp, "%s->input = fft_input;\n", variable);
28 fprintf(fp, "%s->output = fft_output;\n", variable);
29 fprintf(fp, "%s->fft_size = %zu;\n", variable, state->fft_size);
30 fprintf(fp, "%s->input_size = %zu;\n", variable, state->input_size);
31 fprintf(fp, "%s->scratch = fft_scratch;\n", variable);
32 fprintf(fp, "%s->scratch_size = %zu;\n", variable, state->scratch_size);
33 }
34