Files
dragonpilot/selfdrive/modeld/SConscript
George Hotz 59fac9fdc6 Thneed load/save (#19700)
* start thneed load/save

* compiling

* fix loading

* build thneed model in scons

* don't hardcode /data/openpilot

* release files

* those too

* support for loading/saving binary kernels

* save binaries out of json band

* make binary a command line flag to the compiler

* need include assert

* fix shadowed common in SConscript

* cleanup run.h

* hmm, the recurrent buffer wasn't 0ed

* ugh, unique ptr

* remove power constraint, refactor record

* Revert "remove power constraint, refactor record"

This reverts commit bb6fa52db6df59cd9d6420a6f630430e35af8a5e.

* print on thneed stop

* fingers crossed for this one

* recorded

* just curious

* okay okay, pass tests?

* cleanups

* refactor wait

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-01-19 18:08:31 -08:00

66 lines
1.9 KiB
Python

Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc')
lenv = env.Clone()
libs = [cereal, messaging, common, 'OpenCL', 'SNPE', 'symphony-cpu', 'capnp', 'zmq', 'kj', 'yuv', gpucommon, visionipc]
common_src = [
"models/commonmodel.cc",
"runners/snpemodel.cc",
"transforms/loadyuv.cc",
"transforms/transform.cc"
]
thneed_src = [
"thneed/thneed.cc",
"thneed/serialize.cc",
"runners/thneedmodel.cc",
]
if arch == "aarch64" or arch == "larch64":
libs += ['gsl', 'CB']
libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl']
common_src += thneed_src
lenv['CFLAGS'].append("-DUSE_THNEED")
lenv['CXXFLAGS'].append("-DUSE_THNEED")
else:
libs += ['pthread']
# 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 arch == "aarch64" or arch == "larch64":
compiler = lenv.Program('thneed/compile', ["thneed/compile.cc" ]+common_model, LIBS=libs)
cmd = f"cd {Dir('.').get_abspath()} && {compiler[0].get_abspath()} ../../models/supercombo.dlc ../../models/supercombo.thneed --binary"
snpe_path = "/data/pythonpath/phonelibs/snpe/"+arch
cenv = Environment(ENV = {'LD_LIBRARY_PATH' : snpe_path+":"+lenv["ENV"]["LD_LIBRARY_PATH"]})
cenv.Command("../../models/supercombo.thneed", ["../../models/supercombo.dlc", 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)