aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/supported_operators.py
diff options
context:
space:
mode:
authorDwight Lidman <dwight.lidman@arm.com>2020-11-24 13:45:50 +0100
committerpatrik.gustavsson <patrik.gustavsson@arm.com>2020-11-26 07:19:01 +0000
commit0dd21c79ac6ef588e23393064d25e402e16cc2dd (patch)
tree6933d6bd1df37485f7537deed4b19c2e0af805f3 /ethosu/vela/supported_operators.py
parent933f55ea6f686d0cf390f4767e87a391686c3df8 (diff)
downloadethos-u-vela-0dd21c79ac6ef588e23393064d25e402e16cc2dd.tar.gz
MLBEDSW-3558: Put FC on CPU when OFM != 2D
This commit adds a constraint to FullyConnected ops in supported_operators.py that puts any such op on the CPU if tensor dimensions of the output(s) are not 2D. Signed-off-by: Dwight Lidman <dwight.lidman@arm.com> Change-Id: I8c898a780b40fc4a1383c09213f0696ea6699b7d
Diffstat (limited to 'ethosu/vela/supported_operators.py')
-rw-r--r--ethosu/vela/supported_operators.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py
index deae75a2..f7dfec27 100644
--- a/ethosu/vela/supported_operators.py
+++ b/ethosu/vela/supported_operators.py
@@ -247,6 +247,9 @@ class SupportedOperators:
# LeakyRelu specific checks:
self.specific_constraints[Op.LeakyRelu].append(SupportedOperators.constraint_alpha_valid)
+ # FullyConnected specific checks:
+ self.specific_constraints[Op.FullyConnected].append(SupportedOperators.constraint_fc_output_2d)
+
def is_operator_supported(self, op):
ext_type = optype_to_builtintype(op.type)
if op.type not in SupportedOperators.supported_operators:
@@ -409,6 +412,17 @@ class SupportedOperators:
extra.append(tens.name)
return valid, "The following tensor(s) have per-axis quantization parameters: " + ", ".join(extra)
+ @staticmethod
+ def constraint_fc_output_2d(op):
+ "The output tensor(s) must have 2D shape"
+ valid = True
+ extra = []
+ for tens in op.outputs:
+ if len(tens.shape) != 2:
+ valid = False
+ extra.append(f"Tensor '{tens.name}' is {len(tens.shape)}D")
+ return valid, ", ".join(extra)
+
@classmethod
@docstring_format_args([_optype_formatter(supported_fused_activations)])
def constraint_faf(cls, op):