Revert "Revert "MLMBED-3450: Do not convert batched fully connected to conv""
- We have combined estimates for conv and fc, add the fix back
Change-Id: I49a29c716189b37b387df4b46efab5f4e6125994
Signed-off-by: Diqing Zhong <diqing.zhong@arm.com>
diff --git a/ethosu/vela/graph_optimiser.py b/ethosu/vela/graph_optimiser.py
index d0d3d7c..13f08f2 100644
--- a/ethosu/vela/graph_optimiser.py
+++ b/ethosu/vela/graph_optimiser.py
@@ -317,7 +317,7 @@
return op
-def convert_batched_fc_to_conv(op, arch, nng):
+def convert_batched_fc_shape(op, arch, nng):
if op.type == Op.FullyConnected:
ifm = op.inputs[0]
ofm = op.outputs[0]
@@ -327,20 +327,6 @@
batching_split = {4: (2, 2), 8: (2, 4), 16: (4, 4)}
h, w = batching_split.get(n, (1, n))
- # Convert to convolution
- op.name += "_conv"
- op.type = Op.Conv2DBias
- op.attrs = {
- "dilation": (1, 1, 1, 1),
- "dilation_h_factor": 1,
- "dilation_w_factor": 1,
- "padding": b"SAME",
- "stride_h": 1,
- "stride_w": 1,
- "strides": (1, 1, 1, 1),
- "is_converted_fc": True,
- }
-
prev_op = ifm.ops[0]
desired_shape = [1, h, w, ifm.shape[-1]]
if len(ifm.consumer_list) == 1 and prev_op is not None and prev_op.type == Op.Reshape:
@@ -381,7 +367,7 @@
else:
op.outputs[0].set_all_shapes(desired_shape)
else:
- # Add rehape op to the output
+ # Add reshape op to the output
op.set_output_tensor(create_reshape_tensor(ofm, desired_shape, False))
return op
@@ -1096,7 +1082,7 @@
convert_conv_to_fc,
convert_softmax,
fixup_fully_connected_input,
- convert_batched_fc_to_conv,
+ convert_batched_fc_shape,
fixup_pack_input,
unfuse_activation_function,
fixup_conv2d_backprop,