2021-05-08 23:15:17 -06:00
|
|
|
#pragma once
|
2020-01-17 12:20:17 -07:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2021-05-08 23:15:17 -06:00
|
|
|
|
|
|
|
#include "selfdrive/modeld/runners/runmodel.h"
|
2020-01-17 12:20:17 -07:00
|
|
|
|
2020-11-11 21:31:46 -07:00
|
|
|
class ONNXModel : public RunModel {
|
2020-01-17 12:20:17 -07:00
|
|
|
public:
|
2020-11-11 21:31:46 -07:00
|
|
|
ONNXModel(const char *path, float *output, size_t output_size, int runtime);
|
|
|
|
~ONNXModel();
|
2020-01-17 12:20:17 -07:00
|
|
|
void addRecurrent(float *state, int state_size);
|
|
|
|
void addDesire(float *state, int state_size);
|
2020-04-13 14:27:06 -06:00
|
|
|
void addTrafficConvention(float *state, int state_size);
|
2020-02-04 20:46:57 -07:00
|
|
|
void execute(float *net_input_buf, int buf_size);
|
2020-01-17 12:20:17 -07:00
|
|
|
private:
|
2020-02-04 20:46:57 -07:00
|
|
|
int proc_pid;
|
2020-01-17 12:20:17 -07:00
|
|
|
|
|
|
|
float *output;
|
|
|
|
size_t output_size;
|
|
|
|
|
|
|
|
float *rnn_input_buf = NULL;
|
2020-02-04 20:46:57 -07:00
|
|
|
int rnn_state_size;
|
2020-01-17 12:20:17 -07:00
|
|
|
float *desire_input_buf = NULL;
|
2020-02-04 20:46:57 -07:00
|
|
|
int desire_state_size;
|
2020-04-13 14:27:06 -06:00
|
|
|
float *traffic_convention_input_buf = NULL;
|
|
|
|
int traffic_convention_size;
|
2020-02-04 20:46:57 -07:00
|
|
|
|
|
|
|
// pipe to communicate to keras subprocess
|
|
|
|
void pread(float *buf, int size);
|
|
|
|
void pwrite(float *buf, int size);
|
|
|
|
int pipein[2];
|
|
|
|
int pipeout[2];
|
2020-01-17 12:20:17 -07:00
|
|
|
};
|
|
|
|
|