mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 06:33:57 +08:00
* Added wide cam vipc client and bigmodel transform logic
* Added wide_frame to ModelState, should still work normally
* Refactored image input into addImage method, should still work normally
* Updated thneed/compile.cc
* Bigmodel, untested: 44f83118-b375-4d4c-ae12-2017124f0cf4/200
* Have to initialize extra buffer in SNPEModel
* Default paramater value in the wrong place I think
* Move USE_EXTRA to SConscript
* New model: 6c34d59a-acc3-4877-84bd-904c10745ba6/250
* move use extra check to runtime, not on C2
* this is always true
* more C2 checks
* log if frames are out of sync
* more logging on no frame
* store in pointer
* print sof
* add sync logic
* log based on sof difference as well
* keep both models
* less assumptions
* define above thneed
* typo
* simplify
* no need for second client is main is already wide
* more comments update
* no optional reference
* more logging to debug lags
* add to release files
* both defines
* New model: 6831a77f-2574-4bfb-8077-79b0972a2771/950
* Path offset no longer relevant
* Remove duplicate execute
* Moved bigmodel back to big_supercombo.dlc
* add wide vipc stream
* Tici must be tici
* Needs state too
* add wide cam support to model replay
* handle syncing better
* ugh, c2
* print that
* handle ecam lag
* skip first one
* so close
* update refs
Co-authored-by: mitchellgoffpc <mitchellgoffpc@gmail.com>
Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 85efde269d
91 lines
2.7 KiB
Python
91 lines
2.7 KiB
Python
import os
|
|
|
|
Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc')
|
|
lenv = env.Clone()
|
|
|
|
libs = [cereal, messaging, common, visionipc, gpucommon,
|
|
'OpenCL', 'SNPE', 'symphony-cpu', 'capnp', 'zmq', 'kj', 'yuv']
|
|
|
|
def get_dlsym_offset():
|
|
"""Returns the offset between dlopen and dlsym in libdl.so"""
|
|
import ctypes
|
|
libdl = ctypes.PyDLL('libdl.so')
|
|
dlopen = ctypes.cast(libdl.dlopen, ctypes.c_void_p).value
|
|
dlsym = ctypes.cast(libdl.dlsym, ctypes.c_void_p).value
|
|
return dlsym - dlopen
|
|
|
|
|
|
common_src = [
|
|
"models/commonmodel.cc",
|
|
"runners/snpemodel.cc",
|
|
"transforms/loadyuv.cc",
|
|
"transforms/transform.cc"
|
|
]
|
|
|
|
thneed_src = [
|
|
"thneed/thneed.cc",
|
|
"thneed/serialize.cc",
|
|
"thneed/optimizer.cc",
|
|
"runners/thneedmodel.cc",
|
|
]
|
|
|
|
use_thneed = not GetOption('no_thneed')
|
|
|
|
use_extra = True # arch == "larch64"
|
|
lenv['CXXFLAGS'].append('-DUSE_EXTRA=true' if use_extra else '-DUSE_EXTRA=false')
|
|
|
|
if arch == "aarch64" or arch == "larch64":
|
|
libs += ['gsl', 'CB']
|
|
libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl']
|
|
|
|
if use_thneed:
|
|
common_src += thneed_src
|
|
dlsym_offset = get_dlsym_offset()
|
|
lenv['CXXFLAGS'].append("-DUSE_THNEED")
|
|
lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}")
|
|
else:
|
|
libs += ['pthread']
|
|
|
|
if not GetOption('snpe'):
|
|
# for onnx support
|
|
common_src += ['runners/onnxmodel.cc']
|
|
|
|
# tell runners to use onnx
|
|
lenv['CFLAGS'].append("-DUSE_ONNX_MODEL")
|
|
lenv['CXXFLAGS'].append("-DUSE_ONNX_MODEL")
|
|
|
|
if arch == "Darwin":
|
|
# fix OpenCL
|
|
del libs[libs.index('OpenCL')]
|
|
lenv['FRAMEWORKS'] = ['OpenCL']
|
|
|
|
# no SNPE on Mac
|
|
del libs[libs.index('SNPE')]
|
|
del libs[libs.index('symphony-cpu')]
|
|
del common_src[common_src.index('runners/snpemodel.cc')]
|
|
|
|
common_model = lenv.Object(common_src)
|
|
|
|
# build thneed model
|
|
if use_thneed and arch in ("aarch64", "larch64"):
|
|
fn = "../../models/big_supercombo" if use_extra else "../../models/supercombo"
|
|
compiler = lenv.Program('thneed/compile', ["thneed/compile.cc"]+common_model, LIBS=libs)
|
|
cmd = f"cd {Dir('.').abspath} && {compiler[0].abspath} {fn}.dlc {fn}.thneed --binary"
|
|
|
|
lib_paths = ':'.join(Dir(p).abspath for p in lenv["LIBPATH"])
|
|
kernel_path = os.path.join(Dir('.').abspath, "thneed", "kernels")
|
|
cenv = Environment(ENV={'LD_LIBRARY_PATH': f"{lib_paths}:{lenv['ENV']['LD_LIBRARY_PATH']}", 'KERNEL_PATH': kernel_path})
|
|
|
|
kernels = [os.path.join(kernel_path, x) for x in os.listdir(kernel_path) if x.endswith(".cl")]
|
|
cenv.Command(fn + ".thneed", [fn + ".dlc", kernels, compiler], cmd)
|
|
|
|
lenv.Program('_dmonitoringmodeld', [
|
|
"dmonitoringmodeld.cc",
|
|
"models/dmonitoring.cc",
|
|
]+common_model, LIBS=libs)
|
|
|
|
lenv.Program('_modeld', [
|
|
"modeld.cc",
|
|
"models/driving.cc",
|
|
]+common_model, LIBS=libs)
|