aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/test/testutil.py
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-10-14 09:30:02 +0100
committerMichael McGeagh <michael.mcgeagh@arm.com>2020-10-19 12:06:01 +0100
commit1f951fc47abd52db0ac048802dab0c95b149d7b8 (patch)
tree2d4337a75f557813bdac3a9c5a1272a7bbc792b6 /ethosu/vela/test/testutil.py
parentc6ac1944d9934faf6d22825cdd3273afe55432a4 (diff)
downloadethos-u-vela-1f951fc47abd52db0ac048802dab0c95b149d7b8.tar.gz
MLBEDSW-2412 Refactor constraints for conv ops
Using a new system to report constraints, replaced existing functionality for checking conv-like ops. This new system will allow reporting of all constraints regardless of any input network. Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com> Change-Id: If81177deca2a3b57c9dd9a3a08868cbc9cef0c23
Diffstat (limited to 'ethosu/vela/test/testutil.py')
-rw-r--r--ethosu/vela/test/testutil.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ethosu/vela/test/testutil.py b/ethosu/vela/test/testutil.py
index c5ff0033..92bf53dc 100644
--- a/ethosu/vela/test/testutil.py
+++ b/ethosu/vela/test/testutil.py
@@ -72,6 +72,31 @@ def create_elemwise_op(
return op
+def create_op_with_quant_tensors(op_type, ifm_shape, ofm_shape, weights_shape=None, datatype=DataType.uint8):
+ qp = QuantizationParameters()
+ ifm = Tensor(ifm_shape, datatype, "in")
+ ifm.quantization = qp
+ ofm = Tensor(ofm_shape, datatype, "out")
+ ofm.quantization = qp
+ op = Operation(op_type, "op")
+ op.add_input_tensor(ifm)
+ op.set_output_tensor(ofm)
+ # Optional weight tensor
+ if weights_shape is not None:
+ if datatype.size_in_bytes() == 1:
+ np_type = np.uint8
+ elif datatype.size_in_bytes() == 2:
+ np_type = np.int16
+ else:
+ np_type = np.int32
+ qp.zero_point = np.zeros(weights_shape)
+ weights = create_const_tensor(
+ "weights", weights_shape, datatype, np.zeros(weights_shape), np_type, quantization=qp
+ )
+ op.add_input_tensor(weights)
+ return op
+
+
def create_op(op_type, inputs, output, attrs=dict()):
op = Operation(op_type, output.name + "_op")
op.inputs = inputs