Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TensorSpeech
GitHub Repository: TensorSpeech/TensorFlowTTS
Path: blob/master/examples/cpptflite/src/TfliteBase.h
1559 views
1
#ifndef TFLITEBASE_H
2
#define TFLITEBASE_H
3
4
#include "tensorflow/lite/interpreter.h"
5
#include "tensorflow/lite/kernels/register.h"
6
#include "tensorflow/lite/model.h"
7
#include "tensorflow/lite/optional_debug_tools.h"
8
9
#define TFLITE_MINIMAL_CHECK(x) \
10
if (!(x)) { \
11
fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
12
exit(1); \
13
}
14
15
typedef struct
16
{
17
float *melData;
18
std::vector<int32_t> melShape;
19
int32_t bytes;
20
} MelGenData;
21
22
class TfliteBase
23
{
24
public:
25
uint32_t int_size = sizeof(int32_t);
26
uint32_t float_size = sizeof(float);
27
28
std::unique_ptr<tflite::Interpreter> interpreter;
29
30
TfliteBase(const char* modelFilename);
31
~TfliteBase();
32
33
private:
34
std::unique_ptr<tflite::FlatBufferModel> model;
35
tflite::ops::builtin::BuiltinOpResolver resolver;
36
37
void interpreterBuild(const char* modelFilename);
38
};
39
40
#endif // TFLITEBASE_H
41