MLBEDSW-3654 Add/use op ifm/ofm shapes
Add ifm/ofm shapes to op
Changed to rely on these shapes
Signed-off-by: Patrik Gustavsson <patrik.gustavsson@arm.com>
Change-Id: I571535a1dcadc2bdb04a3c727a8e1c49703b174d
diff --git a/ethosu/vela/test/test_graph_optimiser.py b/ethosu/vela/test/test_graph_optimiser.py
index 62a1b76..4537741 100644
--- a/ethosu/vela/test/test_graph_optimiser.py
+++ b/ethosu/vela/test/test_graph_optimiser.py
@@ -32,9 +32,16 @@
weights = create_const_tensor("weight_in", shape, np.uint8, np.zeros(shape))
ofm = Tensor(ifm.shape, np.uint8, "test_out")
op = testutil.create_op(Op.FullyConnected, [ifm, weights], ofm)
+
ifm.consumer_list.append(op)
+ op.ifm_shapes.append([4, 1, 1, 8])
+ op.ofm_shapes.append([4, 1, 1, 8])
+
prev_op = op.clone()
+ prev_op.ifm_shapes = op.ifm_shapes
+ prev_op.ofm_shapes = op.ofm_shapes
+
conv_op = convert_batched_fc_shape(op, None, None)
assert conv_op.ifm != prev_op.ifm
@@ -51,7 +58,13 @@
op = testutil.create_op(Op.FullyConnected, [ifm, weights], ofm)
ifm.consumer_list.append(op)
+ op.ifm_shapes.append([1, 1, 1, 8])
+ op.ofm_shapes.append([1, 1, 1, 8])
+
prev_op = op.clone()
+ prev_op.ifm_shapes = op.ifm_shapes
+ prev_op.ofm_shapes = op.ofm_shapes
+
conv_op = convert_batched_fc_shape(op, None, None)
assert conv_op.ifm == prev_op.ifm
diff --git a/ethosu/vela/test/testutil.py b/ethosu/vela/test/testutil.py
index 9ba39bc..63f841b 100644
--- a/ethosu/vela/test/testutil.py
+++ b/ethosu/vela/test/testutil.py
@@ -69,6 +69,8 @@
ofm = Tensor(ofm_shape, datatype, name + "_ofm")
ofm.quantization = ofm_quant
op.set_output_tensor(ofm)
+ op.set_ifm_ofm_shapes()
+
return op
@@ -104,6 +106,8 @@
qp.zero_point = np.zeros(bias_shape)
bias = create_const_tensor("bias", bias_shape, DataType.int32, np.zeros(bias_shape), np.int32, quantization=qp)
op.add_input_tensor(bias)
+
+ op.set_ifm_ofm_shapes()
return op
@@ -113,6 +117,7 @@
op.outputs = [output]
if attrs is not None:
op.attrs = attrs
+ op.set_ifm_ofm_shapes()
return op