zero out the inputs
MODIFY
extra/thneed.py
extra/thneed.py
@@ -111,10 +111,10 @@ class Thneed:
ptr = nptr
# populate the cl_cache
- for k in jdat['kernels']:
+ for i,k in enumerate(jdat['kernels']):
kernel = prgs[k['name']]
aaa = []
- for i,(a,sz) in enumerate(zip(k['args'], k['args_size'])):
+ for j,(a,sz) in enumerate(zip(k['args'], k['args_size'])):
if len(a) == 0:
aa = cl.LocalMemory(sz)
elif len(a) == 4:
@@ -124,6 +124,7 @@ class Thneed:
a = a.encode('latin_1')
aa = np.uint16(struct.unpack("H", a)[0])
elif len(a) == 8:
+ #print(i,j,struct.unpack("Q", a.encode('latin_1'))[0])
aa = bufs[a]
aaa.append(aa)
self.cl_cache.append((kernel, [k['global_work_size'], k['local_work_size'], *aaa]))

MODIFY
openpilot/compile.py
openpilot/compile.py
@@ -150,6 +150,10 @@ def compile(dat, output_fn):
# but the differences are in unused stuff
print("THNEED ERROR")
for i,(a,b) in enumerate(zip(t.cl_cache, nt.cl_cache)):
+ for j,(c,d) in enumerate(zip(a[1][2:], b[1][2:])):
+ if type(c) == cl.Buffer and c not in t.buffers_to_save:
+ CL.enqueue_copy(c, b'\x00'*c.size)
+ CL.enqueue_copy(d, b'\x00'*d.size)
# rerun
a[0].clprg(CL().cl_queue, *a[1])
CL().cl_queue.finish()
@@ -167,7 +171,7 @@ def compile(dat, output_fn):
if not (cc == dd).all():
print(f"mismatch in layer {i} arg {j}")
np.testing.assert_allclose(cc, dd)
- assert False
+ assert False, "all layers match?"
print("thneed self-test passed!")
except ModuleNotFoundError:
pass

zero out the inputs