@@ -31,13 +31,25 @@ image_flag = {
3131 'larch64' : 'IMAGE=2' ,
3232}.get (arch , 'IMAGE=0' )
3333script_files = [File (Dir ("#selfdrive/modeld" ).File ("compile_warp.py" ).abspath )]
34- compile_warp_cmd = f'{ tg_flags } python3 { Dir ("#selfdrive/modeld" ).abspath } /compile_warp.py '
34+ compile_warp_cmd = f'{ tg_flags } { image_flag } python3 { Dir ("#selfdrive/modeld" ).abspath } /compile_warp.py '
3535from openpilot .common .transformations .camera import _ar_ox_fisheye , _os_fisheye
36+ driving_onnx_deps = [File (f"models/{ m } .onnx" ).abspath for m in ['driving_vision' , 'driving_on_policy' , 'driving_off_policy' ]]
37+ driving_metadata_deps = [File (f"models/{ m } _metadata.pkl" ).abspath for m in ['driving_vision' , 'driving_on_policy' ]]
3638warp_targets = []
39+ policy_pkls = []
3740for cam in [_ar_ox_fisheye , _os_fisheye ]:
3841 w , h = cam .width , cam .height
42+ policy_pkls .append (File (f"models/warp_{ w } x{ h } _tinygrad.pkl" ).abspath )
3943 warp_targets += [File (f"models/warp_{ w } x{ h } _tinygrad.pkl" ).abspath , File (f"models/dm_warp_{ w } x{ h } _tinygrad.pkl" ).abspath ]
40- lenv .Command (warp_targets , tinygrad_files + script_files , compile_warp_cmd )
44+ compile_node = lenv .Command (warp_targets , tinygrad_files + script_files + driving_onnx_deps + driving_metadata_deps + [chunker_file ], compile_warp_cmd )
45+
46+ # chunk the combined policy pkls (they contain model weights)
47+ for policy_pkl in policy_pkls :
48+ onnx_sizes_sum = sum (os .path .getsize (f ) for f in driving_onnx_deps )
49+ chunk_targets = get_chunk_paths (policy_pkl , estimate_pickle_max_size (onnx_sizes_sum ))
50+ def do_chunk (target , source , env , pkl = policy_pkl , chunks = chunk_targets ):
51+ chunk_file (pkl , chunks )
52+ lenv .Command (chunk_targets , compile_node , do_chunk )
4153
4254def tg_compile (flags , model_name ):
4355 pythonpath_string = 'PYTHONPATH="${PYTHONPATH}:' + env .Dir ("#tinygrad_repo" ).abspath + '"'
@@ -58,6 +70,5 @@ def tg_compile(flags, model_name):
5870 do_chunk ,
5971 )
6072
61- # Compile small models
62- for model_name in ['driving_vision' , 'driving_off_policy' , 'driving_on_policy' , 'dmonitoring_model' ]:
63- tg_compile (tg_flags , model_name )
73+ # Compile dmonitoring model (driving models are in the combined policy JIT)
74+ tg_compile (tg_flags , 'dmonitoring_model' )
0 commit comments