2021-05-08 23:15:17 -06:00
|
|
|
#pragma once
|
2020-01-17 12:20:17 -07:00
|
|
|
|
2021-06-08 14:46:22 -06:00
|
|
|
#include <cstdlib>
|
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:
|
2022-02-19 17:06:31 -07:00
|
|
|
ONNXModel(const char *path, float *output, size_t output_size, int runtime, bool use_extra = false);
|
2020-11-11 21:31:46 -07:00
|
|
|
~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);
|
2022-03-15 20:02:21 -06:00
|
|
|
void addCalib(float *state, int state_size);
|
2022-02-19 17:06:31 -07:00
|
|
|
void addImage(float *image_buf, int buf_size);
|
|
|
|
void addExtra(float *image_buf, int buf_size);
|
|
|
|
void execute();
|
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;
|
2022-03-15 20:02:21 -06:00
|
|
|
float *calib_input_buf = NULL;
|
|
|
|
int calib_size;
|
2022-02-19 17:06:31 -07:00
|
|
|
float *image_input_buf = NULL;
|
|
|
|
int image_buf_size;
|
|
|
|
float *extra_input_buf = NULL;
|
|
|
|
int extra_buf_size;
|
|
|
|
bool use_extra;
|
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
|
|
|
};
|
|
|
|
|