From 1bd45ca6e08e85a9986dbddd8fd8c599d97e76bd Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Wed, 20 Nov 2019 15:01:30 +0000 Subject: [PATCH] [Test] add test_array2hexstring --- tests/test_npy2hls.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/test_npy2hls.py diff --git a/tests/test_npy2hls.py b/tests/test_npy2hls.py new file mode 100644 index 000000000..39b594c2f --- /dev/null +++ b/tests/test_npy2hls.py @@ -0,0 +1,14 @@ +from finn.core.datatype import DataType +from finn.core.utils import array2hexstring + + +def test_array2hexstring(): + assert array2hexstring([1, 1, 1, 0], DataType.BINARY, 4) == "e" + assert array2hexstring([1, 1, 1, 0], DataType.BINARY, 8) == "0e" + assert array2hexstring([1, 1, 1, -1], DataType.BIPOLAR, 8) == "0e" + assert array2hexstring([3, 3, 3, 3], DataType.UINT2, 8) == "ff" + assert array2hexstring([1, 3, 3, 1], DataType.UINT2, 8) == "7d" + assert array2hexstring([1, -1, 1, -1], DataType.INT2, 8) == "77" + assert array2hexstring([1, 1, 1, -1], DataType.INT4, 16) == "111f" + assert array2hexstring([-1], DataType.FLOAT32, 32) == "bf800000" + assert array2hexstring([17.125], DataType.FLOAT32, 32) == "41890000" -- GitLab