diff --git a/src/finn/backend/fpgadataflow/utils.py b/src/finn/backend/fpgadataflow/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..272e1e2e3e8a9459af9b508b19576a2fc75b4085 --- /dev/null +++ b/src/finn/backend/fpgadataflow/utils.py @@ -0,0 +1,10 @@ +from finn.core.utils import pack_innermost_dim_as_hex_string + + +def numpy_to_hls_code(ndarray, dtype, pack_innermost_dim=True): + hls_dtype = dtype.get_hls_datatype_str() + if pack_innermost_dim: + idimlen = ndarray.shape[-1] + ndarray = pack_innermost_dim_as_hex_string(ndarray, dtype, idimlen) + hls_dtype = "ap_uint<%d>" % (idimlen * dtype.bitwidth()) + return hls_dtype