model: mse err from 0.02-> 0.000056 (#23891)

* mse err from 0.028070712 -> 5.8073703e-05

* build with weights fixup

* need thneed lib also

* don't break for binaries

* static analysis says i need init

* check the bias

* load_dlc_weights

* nicer scons

* tested scons

* fix static

* pylint issue

* new ref

* a few more asserts

Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com>
old-commit-hash: 8d6f49aecf
This commit is contained in:
George Hotz
2022-03-02 20:52:17 -08:00
committed by GitHub
parent c5753ccf8f
commit 6b52bc6c13
6 changed files with 188 additions and 3 deletions
+10 -2
View File
@@ -67,14 +67,22 @@ common_model = lenv.Object(common_src)
if use_thneed and arch in ("aarch64", "larch64"):
fn = File("#models/supercombo").abspath
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"
cmd = f"cd {Dir('.').abspath} && {compiler[0].abspath} {fn}.dlc {fn}_badweights.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)
cenv.Command(fn + "_badweights.thneed", [fn + ".dlc", kernels, compiler], cmd)
from selfdrive.modeld.thneed.weights_fixup import weights_fixup
def weights_fixup_action(target, source, env):
weights_fixup(target[0].abspath, source[0].abspath, source[1].abspath)
env = Environment(BUILDERS = {'WeightFixup' : Builder(action = weights_fixup_action)})
env.WeightFixup(target=fn + ".thneed", source=[fn+"_badweights.thneed", fn+".dlc"])
lenv.Program('_dmonitoringmodeld', [
"dmonitoringmodeld.cc",