diff --git a/.gitignore b/.gitignore index f05911aef6..4e393b88f0 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,8 @@ selfdrive/modeld/thneed/compile selfdrive/modeld/models/*.thneed selfdrive/modeld/models/*.pkl sunnypilot/modeld/thneed/compile +sunnypilot/modeld/models/*.thneed +sunnypilot/modeld/models/*.pkl *.bz2 *.zst diff --git a/sunnypilot/modeld/SConscript b/sunnypilot/modeld/SConscript index a979c21612..2704974da7 100644 --- a/sunnypilot/modeld/SConscript +++ b/sunnypilot/modeld/SConscript @@ -52,7 +52,14 @@ lenvCython.Program('runners/runmodel_pyx.so', 'runners/runmodel_pyx.pyx', LIBS=c lenvCython.Program('runners/snpemodel_pyx.so', 'runners/snpemodel_pyx.pyx', LIBS=[snpemodel_lib, snpe_lib, *cython_libs], FRAMEWORKS=frameworks, RPATH=snpe_rpath) lenvCython.Program('models/commonmodel_pyx.so', 'models/commonmodel_pyx.pyx', LIBS=[commonmodel_lib, *cython_libs], FRAMEWORKS=frameworks) -if arch == 'larch64' or GetOption('pc_thneed'): +tinygrad_files = ["#"+x for x in glob.glob(env.Dir("#tinygrad_repo").relpath + "/**", recursive=True, root_dir=env.Dir("#").abspath)] + +# Get model metadata +fn = File("models/supercombo").abspath +cmd = f'python3 {Dir("#selfdrive/modeld").abspath}/get_model_metadata.py {fn}.onnx' +lenv.Command(fn + "_metadata.pkl", [fn + ".onnx"] + tinygrad_files, cmd) + +if arch == "larch64": thneed_lib = env.SharedLibrary('thneed', thneed_src, LIBS=[gpucommon, common, 'OpenCL', 'dl']) thneedmodel_lib = env.Library('thneedmodel', ['runners/thneedmodel.cc']) lenvCython.Program('runners/thneedmodel_pyx.so', 'runners/thneedmodel_pyx.pyx', LIBS=envCython["LIBS"]+[thneedmodel_lib, thneed_lib, gpucommon, common, 'dl', 'OpenCL']) diff --git a/sunnypilot/modeld/modeld.py b/sunnypilot/modeld/modeld.py index 9b85cb0846..ea531dfe18 100755 --- a/sunnypilot/modeld/modeld.py +++ b/sunnypilot/modeld/modeld.py @@ -170,7 +170,7 @@ def main(demo=False): if demo: - CP =get_demo_car_params() + CP = get_demo_car_params() else: CP = messaging.log_from_bytes(params.get("CarParams", block=True), car.CarParams) diff --git a/sunnypilot/modeld/models/commonmodel.cc b/sunnypilot/modeld/models/commonmodel.cc index cc4c3ac810..f1e15e5a4e 100644 --- a/sunnypilot/modeld/models/commonmodel.cc +++ b/sunnypilot/modeld/models/commonmodel.cc @@ -47,4 +47,4 @@ ModelFrame::~ModelFrame() { CL_CHECK(clReleaseMemObject(u_cl)); CL_CHECK(clReleaseMemObject(y_cl)); CL_CHECK(clReleaseCommandQueue(q)); -} \ No newline at end of file +} diff --git a/sunnypilot/modeld/models/commonmodel_pyx.pyx b/sunnypilot/modeld/models/commonmodel_pyx.pyx index 46ac575cc2..d66fddea54 100644 --- a/sunnypilot/modeld/models/commonmodel_pyx.pyx +++ b/sunnypilot/modeld/models/commonmodel_pyx.pyx @@ -7,8 +7,8 @@ from libc.string cimport memcpy from msgq.visionipc.visionipc cimport cl_mem from msgq.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 mat3, ModelFrame as cppModelFrame +from openpilot.sunnypilot.modeld.models.commonmodel cimport CL_DEVICE_TYPE_DEFAULT, cl_get_device_id, cl_create_context +from openpilot.sunnypilot.modeld.models.commonmodel cimport mat3, ModelFrame as cppModelFrame cdef class CLContext(BaseCLContext):