mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-13 05:12:11 +08:00
ONNXModel: use the actual model file name (#22084)
* use the actual file name * use macro * fix typo * continue * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 7db04ab0c5e1876f6c6bfe6c407a19c4df80158b
This commit is contained in:
@@ -15,12 +15,15 @@
|
||||
|
||||
void dmonitoring_init(DMonitoringModelState* s) {
|
||||
s->is_rhd = Params().getBool("IsRHD");
|
||||
|
||||
const char *model_path = Hardware::PC() ? "../../models/dmonitoring_model.dlc" : "../../models/dmonitoring_model_q.dlc";
|
||||
s->m = new DefaultRunModel(model_path, &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME);
|
||||
for (int x = 0; x < std::size(s->tensor); ++x) {
|
||||
s->tensor[x] = (x - 128.f) * 0.0078125f;
|
||||
}
|
||||
|
||||
#ifdef USE_ONNX_MODEL
|
||||
s->m = new ONNXModel("../../models/dmonitoring_model.onnx", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME);
|
||||
#else
|
||||
s->m = new SNPEModel("../../models/dmonitoring_model_q.dlc", &s->output[0], OUTPUT_SIZE, USE_DSP_RUNTIME);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -63,10 +63,12 @@ void model_init(ModelState* s, cl_device_id device_id, cl_context context) {
|
||||
constexpr int output_size = OUTPUT_SIZE + TEMPORAL_SIZE;
|
||||
s->output.resize(output_size);
|
||||
|
||||
#if (defined(QCOM) || defined(QCOM2)) && defined(USE_THNEED)
|
||||
#ifdef USE_THNEED
|
||||
s->m = std::make_unique<ThneedModel>("../../models/supercombo.thneed", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
#elif USE_ONNX_MODEL
|
||||
s->m = std::make_unique<ONNXModel>("../../models/supercombo.onnx", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
#else
|
||||
s->m = std::make_unique<DefaultRunModel>("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
s->m = std::make_unique<SNPEModel>("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME);
|
||||
#endif
|
||||
|
||||
#ifdef TEMPORAL
|
||||
|
||||
@@ -15,15 +15,11 @@
|
||||
#include "selfdrive/common/util.h"
|
||||
|
||||
ONNXModel::ONNXModel(const char *path, float *_output, size_t _output_size, int runtime) {
|
||||
LOGD("loading model %s", path);
|
||||
|
||||
output = _output;
|
||||
output_size = _output_size;
|
||||
|
||||
char tmp[1024];
|
||||
strncpy(tmp, path, sizeof(tmp));
|
||||
strstr(tmp, ".dlc")[0] = '\0';
|
||||
strcat(tmp, ".onnx");
|
||||
LOGD("loading model %s", tmp);
|
||||
|
||||
int err = pipe(pipein);
|
||||
assert(err == 0);
|
||||
err = pipe(pipeout);
|
||||
@@ -35,7 +31,7 @@ ONNXModel::ONNXModel(const char *path, float *_output, size_t _output_size, int
|
||||
proc_pid = fork();
|
||||
if (proc_pid == 0) {
|
||||
LOGD("spawning onnx process %s", onnx_runner.c_str());
|
||||
char *argv[] = {(char*)onnx_runner.c_str(), tmp, NULL};
|
||||
char *argv[] = {(char*)onnx_runner.c_str(), (char*)path, nullptr};
|
||||
dup2(pipein[0], 0);
|
||||
dup2(pipeout[1], 1);
|
||||
close(pipein[0]);
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
#include "runmodel.h"
|
||||
#include "snpemodel.h"
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
#if defined(USE_THNEED)
|
||||
#include "thneedmodel.h"
|
||||
#define DefaultRunModel SNPEModel
|
||||
#else
|
||||
#ifdef USE_ONNX_MODEL
|
||||
#elif defined(USE_ONNX_MODEL)
|
||||
#include "onnxmodel.h"
|
||||
#define DefaultRunModel ONNXModel
|
||||
#else
|
||||
#define DefaultRunModel SNPEModel
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user