-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedgetpu.h
46 lines (36 loc) · 961 Bytes
/
edgetpu.h
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
#ifndef EDGETPU_H
#define EDGETPU_H
#include <map>
#include <string>
#include "tensorflow/lite/interpreter.h"
#include "position.h"
class ChessRepr {
public:
ChessRepr();
int plane_index(uint32_t, int);
private:
bool is_knight_move(int from_square, int to_square);
std::map<int, int> queen_indexes;
std::map<int, int> knight_indexes;
std::map<int, std::map<int, int>> underpromo_indexes;
};
class EdgeTpuModel {
public:
EdgeTpuModel(const std::string model_name);
void predict(position_t);
void test();
bool has_changed_on_disc();
float get_value();
float get_logit(uint32_t move, int eor);
float get_win_probability();
float get_draw_probability();
float get_loss_probability();
float get_moves_left();
private:
std::string model_name;
std::unique_ptr<tflite::Interpreter> interpreter;
ChessRepr repr;
time_t mtime;
time_t get_modification_time();
};
#endif