aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-11-09 11:11:26 +0000
committerMichael McGeagh <michael.mcgeagh@arm.com>2020-11-09 11:11:26 +0000
commit219ec070cb0d1aab6b2ea8d0428d6aaa9c5c07fb (patch)
treea99e726497545bcbabcd506bd48582d2fa5150ea
parentfad90c2db9e1b3f19f3a3700b17cf69ed08aea04 (diff)
downloadethos-u-vela-219ec070cb0d1aab6b2ea8d0428d6aaa9c5c07fb.tar.gz
MLBEDSW-3402 SupportedOp now returns external name
Previously the internal operator type was printed when checking the supported operator checks. This now converts that back to the external type name. Additionally removed dead code and changed the message for cpu-only ops Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com> Change-Id: Ib2b0cbcb49fdf63edb835828e266b079e63bae37
-rw-r--r--ethosu/vela/supported_operators.py10
-rw-r--r--ethosu/vela/tflite_mapping.py8
2 files changed, 12 insertions, 6 deletions
diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py
index ddfb8ed..04cda1d 100644
--- a/ethosu/vela/supported_operators.py
+++ b/ethosu/vela/supported_operators.py
@@ -25,6 +25,7 @@ from .numeric_util import is_integer
from .operation import get_slice_offsets
from .operation import Op
from .tensor import check_quantized_tens_scaling_equal
+from .tflite_mapping import optype_to_builtintype
# Custom decorator function to allow formatting docstrings containing "{}"
@@ -36,10 +37,6 @@ def docstring_format_args(args):
return docstring
-def warn_cpu(op, msg):
- print("Warning: {} {}, placing on CPU".format(op.type, msg))
-
-
class SupportedOperators:
# Categorised lists of supported operators
npu_pre_ops = set((Op.SplitSliceRead,))
@@ -232,15 +229,16 @@ class SupportedOperators:
self.specific_constraints[Op.LeakyRelu].append(SupportedOperators.constraint_alpha_valid)
def is_operator_supported(self, op):
+ ext_type = optype_to_builtintype(op.type)
if op.type not in SupportedOperators.supported_operators:
if op.type not in (Op.Placeholder, Op.SubgraphInput, Op.Const):
- print(f"Info: {op.type} '{op.name}' is not supported on the NPU. Placing on CPU instead")
+ print(f"Info: {ext_type} '{op.name}' is a CPU only op")
return False
for constraint in self.generic_constraints + self.specific_constraints[op.type]:
valid, extra = constraint(op)
if not valid:
- print(f"Warning: {op.type} '{op.name}' is not supported on the NPU. Placing on CPU instead")
+ print(f"Warning: {ext_type} '{op.name}' is not supported on the NPU. Placing on CPU instead")
print(f" - {constraint.__doc__}")
if extra:
print(f" {extra}")
diff --git a/ethosu/vela/tflite_mapping.py b/ethosu/vela/tflite_mapping.py
index 8a53039..bbd44b0 100644
--- a/ethosu/vela/tflite_mapping.py
+++ b/ethosu/vela/tflite_mapping.py
@@ -689,3 +689,11 @@ builtin_operator_map = {
builtin_operator_inv_map = {v[0]: (k, v[1]) for k, v in builtin_operator_map.items()}
builtin_operator_inv_map[Op.CustomNpuOp] = (BuiltinOperator.CUSTOM, CustomOptionsSerializer())
+
+
+def optype_to_builtintype(op_type):
+ if op_type in builtin_operator_inv_map:
+ builtin_type = builtin_operator_inv_map[op_type][0]
+ return next(k for k, v in vars(BuiltinOperator).items() if v == builtin_type)
+ else:
+ return "UNKNOWN"