From 8453c02e9ece50b8024fb3ccf88721a4e86d438f Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Fri, 29 Nov 2019 00:46:22 +0000 Subject: [PATCH] [Util] support more int types in gen_finn_dt_tensor --- src/finn/core/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/finn/core/utils.py b/src/finn/core/utils.py index 12c34d8a5..05e3adf1f 100644 --- a/src/finn/core/utils.py +++ b/src/finn/core/utils.py @@ -185,8 +185,10 @@ def gen_finn_dt_tensor(finn_dt, tensor_shape): tensor_values = np.random.randint(2, size=tensor_shape) elif finn_dt == DataType.TERNARY: tensor_values = np.random.randint(-1, high=1, size=tensor_shape) - elif finn_dt == DataType.INT2: - tensor_values = np.random.randint(-2, high=1, size=tensor_shape) + elif "INT" in finn_dt.name: + tensor_values = np.random.randint( + finn_dt.min(), high=finn_dt.max(), size=tensor_shape + ) else: raise ValueError( "Datatype {} is not supported, no tensor could be generated".format(finn_dt) -- GitLab