From 3255971a072aed37b3aec11a69ba7f05255ef01f Mon Sep 17 00:00:00 2001 From: Luke Hutton Date: Fri, 26 Nov 2021 10:59:16 +0000 Subject: [PATCH] remove uneccesary function Change-Id: Ifc1b4c34cd891fce35d3e043ba81afdd2e34fc4e --- .../relay/backend/contrib/ethosu/codegen.py | 5 +---- .../tvm/relay/backend/contrib/ethosu/util.py | 20 ------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/python/tvm/relay/backend/contrib/ethosu/codegen.py b/python/tvm/relay/backend/contrib/ethosu/codegen.py index 8aa6064e1b52..67f545fa8c51 100644 --- a/python/tvm/relay/backend/contrib/ethosu/codegen.py +++ b/python/tvm/relay/backend/contrib/ethosu/codegen.py @@ -25,7 +25,6 @@ from tvm.relay.backend.contrib.ethosu import tir_to_cs_translator from tvm.relay.backend.contrib.ethosu import util from tvm.relay.backend.contrib.ethosu import op as ethosu_op -from tvm.relay.backend.contrib.ethosu.util import is_ethosu_op from tvm.relay.expr_functor import ExprMutator from tvm.relay.backend.contrib.ethosu.op import op_attrs # pylint: disable=unused-import @@ -148,8 +147,6 @@ def alter_ethosu_op_layout(self, call: tvm.relay.expr.Call) -> tvm.relay.expr.Ca else: self.children[input_arg] = [new_call] - print(new_call) - return super().visit_call(new_call) def visit_call(self, call: tvm.relay.expr.Call) -> tvm.relay.expr.Call: @@ -168,7 +165,7 @@ def visit_call(self, call: tvm.relay.expr.Call) -> tvm.relay.expr.Call: not refer to an Op. Else, a new call node with altered Op attributes. """ - if is_ethosu_op(call) and call.op.name != "contrib.ethosu.identity": + if isinstance(call.op, tvm.ir.op.Op) and call.op.name in self.optimize_op: return self.alter_ethosu_op_layout(call) return super().visit_call(call) diff --git a/python/tvm/relay/backend/contrib/ethosu/util.py b/python/tvm/relay/backend/contrib/ethosu/util.py index 5eb11558be05..589ab21b3998 100644 --- a/python/tvm/relay/backend/contrib/ethosu/util.py +++ b/python/tvm/relay/backend/contrib/ethosu/util.py @@ -139,26 +139,6 @@ def is_composite_func(func: relay.Function, name: str) -> bool: return composite_name == name -def is_ethosu_op(expr: tvm.relay.Expr) -> bool: - """Checks whether a relay expression is an NPU operator or not. - - Parameters - ---------- - expr : tvm.relay.Expr - The expression to check. - - Returns - ------- - bool - True if the expression is an EthosU operation, false if not. - """ - return ( - isinstance(expr, tvm.relay.expr.Call) - and isinstance(expr.op, tvm.ir.op.Op) - and "contrib.ethosu" in expr.op.name - ) - - def get_range_for_dtype_str(dtype: str) -> Tuple[int, int]: """ Produce the min,max for a give data type.