Skip to content
Snippets Groups Projects
Commit 40514ced authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[Lookup] reverse output layout + associated fixes

parent 9247856b
No related branches found
No related tags found
No related merge requests found
...@@ -186,7 +186,7 @@ class Lookup(HLSCustomOp): ...@@ -186,7 +186,7 @@ class Lookup(HLSCustomOp):
oshape_cpp_str = str(oshape).replace("(", "{").replace(")", "}") oshape_cpp_str = str(oshape).replace("(", "{").replace(")", "}")
self.code_gen_dict["$DATAOUTSTREAM$"] = [ self.code_gen_dict["$DATAOUTSTREAM$"] = [
'apintstream2npy<%s, %s, %d, %s>(out, %s, "%s");' 'apintstream2npy<%s, %s, %d, %s>(out, %s, "%s", %s);'
% ( % (
packed_hls_type, packed_hls_type,
elem_hls_type, elem_hls_type,
...@@ -194,6 +194,7 @@ class Lookup(HLSCustomOp): ...@@ -194,6 +194,7 @@ class Lookup(HLSCustomOp):
npy_type, npy_type,
oshape_cpp_str, oshape_cpp_str,
npy_out, npy_out,
"false",
) )
] ]
...@@ -245,8 +246,11 @@ class Lookup(HLSCustomOp): ...@@ -245,8 +246,11 @@ class Lookup(HLSCustomOp):
assert np.vectorize(edt.allowed)( assert np.vectorize(edt.allowed)(
embeddings embeddings
).all(), "Embeddings can't be expressed with type %s" % str(edt) ).all(), "Embeddings can't be expressed with type %s" % str(edt)
# reverse innertmost dim in embeddings to remain compatible with
# how we normally encode the data in FINN
embeddings_rev = np.flip(embeddings, -1)
embeddings_hls_code = numpy_to_hls_code( embeddings_hls_code = numpy_to_hls_code(
embeddings, edt, "embeddings", True, False embeddings_rev, edt, "embeddings", True, False
) )
f_thresh = open(weight_filename, "w") f_thresh = open(weight_filename, "w")
f_thresh.write(embeddings_hls_code) f_thresh.write(embeddings_hls_code)
...@@ -310,7 +314,7 @@ class Lookup(HLSCustomOp): ...@@ -310,7 +314,7 @@ class Lookup(HLSCustomOp):
out_shape, out_shape,
packed_bits, packed_bits,
target_bits, target_bits,
reverse_inner=False, reverse_inner=True,
) )
# load and reshape output # load and reshape output
output = np.load(out_npy_path) output = np.load(out_npy_path)
......
...@@ -124,7 +124,7 @@ def test_fpgadataflow_lookup(edt, embedding_cfg, exec_mode): ...@@ -124,7 +124,7 @@ def test_fpgadataflow_lookup(edt, embedding_cfg, exec_mode):
model = model.transform(SetExecMode("cppsim")) model = model.transform(SetExecMode("cppsim"))
elif exec_mode == "rtlsim": elif exec_mode == "rtlsim":
model = model.transform(GiveUniqueNodeNames()) model = model.transform(GiveUniqueNodeNames())
model = model.transform(PrepareIP("xc7z020clg400-1", 10)) model = model.transform(PrepareIP("xczu3eg-sbva484-1-e", 10))
model = model.transform(HLSSynthIP()) model = model.transform(HLSSynthIP())
model = model.transform(SetExecMode("rtlsim")) model = model.transform(SetExecMode("rtlsim"))
model = model.transform(PrepareRTLSim()) model = model.transform(PrepareRTLSim())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment