tflite_wrapper.hpp 761 B

12345678910111213141516171819202122232425262728
  1. #ifndef inferencer_hpp
  2. #define inferencer_hpp
  3. #ifdef __ANDROID__
  4. #include "tensorflow/lite/model_builder.h"
  5. #include "tensorflow/lite/kernels/register.h"
  6. #else
  7. #include <c_api.h>
  8. #endif
  9. #include <stdio.h>
  10. class TfliteWrapper {
  11. private:
  12. #ifdef __ANDROID__
  13. std::unique_ptr<tflite::FlatBufferModel> model;
  14. std::unique_ptr<tflite::Interpreter> interpreter;
  15. TfLiteDelegate* delegate;
  16. #else
  17. TfLiteModel* model;
  18. TfLiteDelegate* delegate;
  19. TfLiteInterpreter *interpreter;
  20. #endif
  21. public:
  22. TfliteWrapper(const char *modelPath);
  23. void Invoke(const void* input_data, size_t input_data_size, void* output_data, size_t output_data_size);
  24. void getInputShape(uint32_t *shape, size_t size);
  25. ~TfliteWrapper();
  26. };
  27. #endif /* inferencer_hpp */