mnn_handler.h
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Created by DefTruth on 2021/10/6.
//
#ifndef LITE_AI_TOOLKIT_MNN_CORE_MNN_HANDLER_H
#define LITE_AI_TOOLKIT_MNN_CORE_MNN_HANDLER_H
#include "mnn_config.h"
namespace mnncore
{
class LITE_EXPORTS BasicMNNHandler
{
protected:
std::shared_ptr<MNN::Interpreter> mnn_interpreter;
MNN::Session *mnn_session = nullptr;
MNN::Tensor *input_tensor = nullptr; // assume single input.
MNN::ScheduleConfig schedule_config;
std::shared_ptr<MNN::CV::ImageProcess> pretreat; // init at subclass
const char *log_id = nullptr;
const char *mnn_path = nullptr;
protected:
const unsigned int num_threads; // initialize at runtime.
int input_batch;
int input_channel;
int input_height;
int input_width;
int dimension_type;
int num_outputs = 1;
protected:
explicit BasicMNNHandler(const std::string &_mnn_path, unsigned int _num_threads = 1);
virtual ~BasicMNNHandler();
// un-copyable
protected:
BasicMNNHandler(const BasicMNNHandler &) = delete; //
BasicMNNHandler(BasicMNNHandler &&) = delete; //
BasicMNNHandler &operator=(const BasicMNNHandler &) = delete; //
BasicMNNHandler &operator=(BasicMNNHandler &&) = delete; //
protected:
virtual void transform(const cv::Mat &mat) = 0; // ? needed ?
private:
void initialize_handler();
void print_debug_string();
};
}
#endif //LITE_AI_TOOLKIT_MNN_CORE_MNN_HANDLER_H