diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 6044932cc8..2920a2693c 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -14,7 +14,8 @@ from openpilot.common.params import Params from openpilot.common.filter_simple import FirstOrderFilter from openpilot.common.realtime import config_realtime_process from openpilot.common.transformations.model import get_warp_matrix -from openpilot.selfdrive.modeld.models.commonmodel_pyx import ModelFrame, CLContext, Runtime +from openpilot.selfdrive.modeld.runners.runmodel_pyx import Runtime +from openpilot.selfdrive.modeld.models.commonmodel_pyx import ModelFrame, CLContext from openpilot.selfdrive.modeld.models.driving_pyx import ( PublishState, create_model_msg, create_pose_msg, FEATURE_LEN, HISTORY_BUFFER_LEN, DESIRE_LEN, TRAFFIC_CONVENTION_LEN, NAV_FEATURE_LEN, NAV_INSTRUCTION_LEN, diff --git a/selfdrive/modeld/models/commonmodel.pxd b/selfdrive/modeld/models/commonmodel.pxd index d313dbef90..9f3f9bf27b 100644 --- a/selfdrive/modeld/models/commonmodel.pxd +++ b/selfdrive/modeld/models/commonmodel.pxd @@ -16,8 +16,3 @@ cdef extern from "selfdrive/modeld/models/commonmodel.h": int buf_size ModelFrame(cl_device_id, cl_context) float * prepare(cl_mem, int, int, int, int, mat3, cl_mem*) - -cdef extern from "selfdrive/modeld/runners/runmodel.h": - cdef int USE_CPU_RUNTIME - cdef int USE_GPU_RUNTIME - cdef int USE_DSP_RUNTIME diff --git a/selfdrive/modeld/models/commonmodel_pyx.pyx b/selfdrive/modeld/models/commonmodel_pyx.pyx index c5576a5acb..88b0d16c99 100644 --- a/selfdrive/modeld/models/commonmodel_pyx.pyx +++ b/selfdrive/modeld/models/commonmodel_pyx.pyx @@ -8,14 +8,8 @@ from libc.string cimport memcpy from cereal.visionipc.visionipc cimport cl_mem from cereal.visionipc.visionipc_pyx cimport VisionBuf, CLContext as BaseCLContext from .commonmodel cimport CL_DEVICE_TYPE_DEFAULT, cl_get_device_id, cl_create_context -from .commonmodel cimport USE_CPU_RUNTIME, USE_GPU_RUNTIME, USE_DSP_RUNTIME from .commonmodel cimport mat3, ModelFrame as cppModelFrame -class Runtime: - CPU = USE_CPU_RUNTIME - GPU = USE_GPU_RUNTIME - DSP = USE_DSP_RUNTIME - cdef class CLContext(BaseCLContext): def __cinit__(self): self.device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT) diff --git a/selfdrive/modeld/runners/runmodel.pxd b/selfdrive/modeld/runners/runmodel.pxd index f12f3e7ab9..01b2a9cf2c 100644 --- a/selfdrive/modeld/runners/runmodel.pxd +++ b/selfdrive/modeld/runners/runmodel.pxd @@ -3,6 +3,10 @@ from libcpp.string cimport string cdef extern from "selfdrive/modeld/runners/runmodel.h": + cdef int USE_CPU_RUNTIME + cdef int USE_GPU_RUNTIME + cdef int USE_DSP_RUNTIME + cdef cppclass RunModel: void addInput(string, float*, int) void setInputBuffer(string, float*, int) diff --git a/selfdrive/modeld/runners/runmodel_pyx.pyx b/selfdrive/modeld/runners/runmodel_pyx.pyx index a35f0fa280..cdc62a79be 100644 --- a/selfdrive/modeld/runners/runmodel_pyx.pyx +++ b/selfdrive/modeld/runners/runmodel_pyx.pyx @@ -4,8 +4,14 @@ from libcpp.string cimport string from libc.string cimport memcpy +from .runmodel cimport USE_CPU_RUNTIME, USE_GPU_RUNTIME, USE_DSP_RUNTIME from selfdrive.modeld.models.commonmodel_pyx cimport CLMem +class Runtime: + CPU = USE_CPU_RUNTIME + GPU = USE_GPU_RUNTIME + DSP = USE_DSP_RUNTIME + cdef class RunModel: def __dealloc__(self): del self.model