Files
dragonpilot/selfdrive/modeld/runners/thneedmodel.cc
Dean Lee 7222d0f20d Cleanup selfdrive/ includes (#20822)
* cleanup include path

* continue

* format includes

* fix testraw.cc

* remove include path from SConstruct

* regroup

* rebase master

* almost done

* apply review

* rename FileReader.xx to filereader.xx

* rename Unlogger.x->unlogger.x

* rename FrameReader.xx -> framereader.xx

* apply reviews

* ui.h

* continue

* fix framebuffer.cc build error:mv util.h up

* full path to msm_media_info

* fix qcom2 camerad

Co-authored-by: Comma Device <device@comma.ai>
2021-05-08 22:15:17 -07:00

43 lines
963 B
C++

#include "thneedmodel.h"
#include <assert.h>
ThneedModel::ThneedModel(const char *path, float *loutput, size_t loutput_size, int runtime) {
thneed = new Thneed(true);
thneed->record = 0;
thneed->load(path);
thneed->clexec();
thneed->find_inputs_outputs();
recorded = false;
output = loutput;
}
void ThneedModel::addRecurrent(float *state, int state_size) {
recurrent = state;
}
void ThneedModel::addTrafficConvention(float *state, int state_size) {
trafficConvention = state;
}
void ThneedModel::addDesire(float *state, int state_size) {
desire = state;
}
void ThneedModel::execute(float *net_input_buf, int buf_size) {
float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf};
if (!recorded) {
thneed->record = THNEED_RECORD;
thneed->copy_inputs(inputs);
thneed->clexec();
thneed->copy_output(output);
thneed->stop();
recorded = true;
} else {
thneed->execute(inputs, output);
}
}