|
|
|
@ -6,15 +6,6 @@ lenv = env.Clone() |
|
|
|
|
libs = [cereal, messaging, common, visionipc, gpucommon, |
|
|
|
|
'OpenCL', 'SNPE', '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", |
|
|
|
@ -36,9 +27,7 @@ if arch == "larch64": |
|
|
|
|
|
|
|
|
|
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'] |
|
|
|
|
|
|
|
|
@ -60,12 +49,9 @@ else: |
|
|
|
|
del libs[libs.index('SNPE')] |
|
|
|
|
del common_src[common_src.index('runners/snpemodel.cc')] |
|
|
|
|
|
|
|
|
|
onnxrunner_path = File("runners/onnx_runner.py").abspath |
|
|
|
|
transform_path = File("transforms/transform.cl").abspath |
|
|
|
|
loadyuv_path = File("transforms/loadyuv.cl").abspath |
|
|
|
|
lenv['CXXFLAGS'].append(f'-DTRANSFORM_PATH=\\"{transform_path}\\"') |
|
|
|
|
lenv['CXXFLAGS'].append(f'-DLOADYUV_PATH=\\"{loadyuv_path}\\"') |
|
|
|
|
lenv['CXXFLAGS'].append(f'-DONNXRUNNER_PATH=\\"{onnxrunner_path}\\"') |
|
|
|
|
for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl', 'ONNXRUNNER': 'runners/onnx_runner.py'}.items(): |
|
|
|
|
path = File(fn).abspath |
|
|
|
|
lenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{path}\\"') |
|
|
|
|
|
|
|
|
|
common_model = lenv.Object(common_src) |
|
|
|
|
|
|
|
|
@ -74,8 +60,13 @@ lenv.Program('_dmonitoringmodeld', [ |
|
|
|
|
"models/dmonitoring.cc", |
|
|
|
|
]+common_model, LIBS=libs) |
|
|
|
|
|
|
|
|
|
lenv.Program('_navmodeld', [ |
|
|
|
|
"navmodeld.cc", |
|
|
|
|
"models/nav.cc", |
|
|
|
|
]+common_model, LIBS=libs) |
|
|
|
|
|
|
|
|
|
# build thneed model |
|
|
|
|
if use_thneed and arch == "larch64" or GetOption('pc_thneed'): |
|
|
|
|
if (use_thneed and arch == "larch64") or GetOption('pc_thneed'): |
|
|
|
|
fn = File("models/supercombo").abspath |
|
|
|
|
|
|
|
|
|
tinygrad_opts = ["NATIVE_EXPLOG=1", "VALIDHACKS=1", "OPTLOCAL=1", "IMAGE=2", "GPU=1", "ENABLE_METHOD_CACHE=1"] |
|
|
|
@ -104,8 +95,3 @@ llenv.Program('_modeld', [ |
|
|
|
|
"modeld.cc", |
|
|
|
|
"models/driving.cc", |
|
|
|
|
]+common_model, LIBS=libs + transformations) |
|
|
|
|
|
|
|
|
|
lenv.Program('_navmodeld', [ |
|
|
|
|
"navmodeld.cc", |
|
|
|
|
"models/nav.cc", |
|
|
|
|
]+common_model, LIBS=libs + transformations) |
|
|
|
|