mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-02 14:13:44 +08:00
1a8dd310ae
* Add support for TinyGrad model runner processing Introduced a new function `is_tinygrad_model` to detect TinyGrad as an active model runner. Updated the `is_stock_model` logic to account for TinyGrad models and added a new process entry for TinyGrad in the model manager. This enables handling TinyGrad models alongside existing configurations. adding modeld back Add support for `modeld_v2` and update paths for consistency Updated `SConscript` files to integrate `modeld_v2` alongside `modeld` and adjusted script paths for correct metadata handling. Adjusted various configurations and scripts, such as `labeler.yaml` and `build_release.sh`, to include `modeld_v2` and ensure cohesive project structure. Refactor imports to use updated `modeld_v2` paths. Replaced outdated `modeld` references with their `modeld_v2` counterparts for consistency and clarity across the codebase. Also updated `.gitignore` to accommodate new directory structure. This change ensures better maintainability and alignment with the new directory schema. Refactor and reorganize modeld to sunnypilot/modeld_v2 structure. Moved and renamed `modeld` components to the new `sunnypilot/modeld_v2` directory for better organization and modularity. Updated imports and file references to align with the new structure, ensuring compatibility and functionality. Streamlined project structure to improve maintainability and future development. * typo * Use `stock` model runner and refactor model checks. Replaces outdated model detection logic with unified `stock` runner integration, simplifying the decision flow for model selection. Includes `stock` as a new enum in the `Runner` type and updates affected references accordingly. * Handle missing 'sim_pose' in model outputs gracefully. Added conditional checks to ensure the code handles cases where 'sim_pose' is absent in the model outputs. Fallback behaviors use 'plan' data when 'sim_pose' is unavailable, preventing potential errors and enhancing robustness.
66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
import glob
|
|
|
|
Import('env', 'envCython', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'transformations')
|
|
lenv = env.Clone()
|
|
lenvCython = envCython.Clone()
|
|
|
|
libs = [cereal, messaging, visionipc, gpucommon, common, 'capnp', 'kj', 'pthread']
|
|
frameworks = []
|
|
|
|
common_src = [
|
|
"models/commonmodel.cc",
|
|
"transforms/loadyuv.cc",
|
|
"transforms/transform.cc",
|
|
]
|
|
|
|
thneed_src_common = [
|
|
"thneed/thneed_common.cc",
|
|
"thneed/serialize.cc",
|
|
]
|
|
|
|
thneed_src_qcom = thneed_src_common + ["thneed/thneed_qcom2.cc"]
|
|
thneed_src_pc = thneed_src_common + ["thneed/thneed_pc.cc"]
|
|
thneed_src = thneed_src_qcom if arch == "larch64" else thneed_src_pc
|
|
|
|
# SNPE except on Mac and ARM Linux
|
|
snpe_lib = []
|
|
if arch != "Darwin" and arch != "aarch64":
|
|
common_src += ['runners/snpemodel.cc']
|
|
snpe_lib += ['SNPE']
|
|
|
|
# OpenCL is a framework on Mac
|
|
if arch == "Darwin":
|
|
frameworks += ['OpenCL']
|
|
else:
|
|
libs += ['OpenCL']
|
|
|
|
# Set path definitions
|
|
for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transforms/loadyuv.cl'}.items():
|
|
for xenv in (lenv, lenvCython):
|
|
xenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{File(fn).abspath}\\"')
|
|
|
|
# Compile cython
|
|
snpe_rpath_qcom = "/data/pythonpath/third_party/snpe/larch64"
|
|
snpe_rpath_pc = f"{Dir('#').abspath}/third_party/snpe/x86_64-linux-clang"
|
|
snpe_rpath = lenvCython['RPATH'] + [snpe_rpath_qcom if arch == "larch64" else snpe_rpath_pc]
|
|
|
|
cython_libs = envCython["LIBS"] + libs
|
|
snpemodel_lib = lenv.Library('snpemodel', ['runners/snpemodel.cc'])
|
|
commonmodel_lib = lenv.Library('commonmodel', common_src)
|
|
|
|
lenvCython.Program('runners/runmodel_pyx.so', 'runners/runmodel_pyx.pyx', LIBS=cython_libs, FRAMEWORKS=frameworks)
|
|
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)
|
|
|
|
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("#sunnypilot/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'])
|