diff --git a/selfdrive/modeld/models/dmonitoring.cc b/selfdrive/modeld/models/dmonitoring.cc index 1f8ca1fcea..2711db45ef 100644 --- a/selfdrive/modeld/models/dmonitoring.cc +++ b/selfdrive/modeld/models/dmonitoring.cc @@ -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 diff --git a/selfdrive/modeld/models/driving.cc b/selfdrive/modeld/models/driving.cc index 3fb6f56255..0ebb9a374b 100644 --- a/selfdrive/modeld/models/driving.cc +++ b/selfdrive/modeld/models/driving.cc @@ -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("../../models/supercombo.thneed", &s->output[0], output_size, USE_GPU_RUNTIME); +#elif USE_ONNX_MODEL + s->m = std::make_unique("../../models/supercombo.onnx", &s->output[0], output_size, USE_GPU_RUNTIME); #else - s->m = std::make_unique("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME); + s->m = std::make_unique("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME); #endif #ifdef TEMPORAL diff --git a/selfdrive/modeld/runners/onnxmodel.cc b/selfdrive/modeld/runners/onnxmodel.cc index 7ae107cb48..cd56f6c21b 100644 --- a/selfdrive/modeld/runners/onnxmodel.cc +++ b/selfdrive/modeld/runners/onnxmodel.cc @@ -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]); diff --git a/selfdrive/modeld/runners/run.h b/selfdrive/modeld/runners/run.h index 3051dfb03a..c64f300fe2 100644 --- a/selfdrive/modeld/runners/run.h +++ b/selfdrive/modeld/runners/run.h @@ -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