You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ma...@apache.org on 2022/07/08 14:46:28 UTC

[tvm] branch main updated: [microNPU] Test averge pool partitioning (#11965)

This is an automated email from the ASF dual-hosted git repository.

manupa pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new f769f4e2cc [microNPU] Test averge pool partitioning (#11965)
f769f4e2cc is described below

commit f769f4e2cc9f00c1d5cbf0b312dae7bfa2404841
Author: Luke Hutton <lu...@arm.com>
AuthorDate: Fri Jul 8 15:46:18 2022 +0100

    [microNPU] Test averge pool partitioning (#11965)
    
    Follow up for #11469.
    
    Change-Id: I474b1d43d3abc6b66d35ebcf3ad6fea50becfb97
---
 tests/python/contrib/test_ethosu/test_partition.py | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/tests/python/contrib/test_ethosu/test_partition.py b/tests/python/contrib/test_ethosu/test_partition.py
new file mode 100644
index 0000000000..578485c8aa
--- /dev/null
+++ b/tests/python/contrib/test_ethosu/test_partition.py
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=wrong-import-position
+
+"""
+Tests to check that the NPU partitioning frontend partitions
+only supported operations.
+"""
+
+import pytest
+
+pytest.importorskip("ethosu.vela")
+
+import tvm
+from tvm import relay
+from tvm.relay.op.contrib import ethosu
+
+
+@pytest.mark.parametrize(
+    "count_include_pad,pool_shape,padding",
+    [
+        (True, [2, 2], [0, 0, 0, 0]),
+        (False, [2, 2], [4, 4, 5, 5]),
+        (False, [9, 9], [1, 1, 1, 1]),
+    ],
+)
+def test_invalid_avg_pool2d(count_include_pad, pool_shape, padding):
+    """
+    Test unsupported variants of avg_pool2d don't get partitioned.
+    """
+    ifm_shape = [1, 4, 4, 3]
+    strides = [2, 2]
+
+    def get_graph():
+        x = relay.var("x", shape=ifm_shape, dtype="int8")
+        x = relay.cast(x, dtype="int32")
+        x = relay.nn.avg_pool2d(
+            x,
+            pool_shape,
+            strides,
+            padding=padding,
+            layout="NHWC",
+            count_include_pad=count_include_pad,
+        )
+        x = relay.cast(x, dtype="int8")
+        func = relay.Function(relay.analysis.free_vars(x), x)
+        return tvm.IRModule.from_expr(func)
+
+    mod = relay.transform.InferType()(get_graph())
+    partitioned_mod = ethosu.partition_for_ethosu(mod)
+    assert tvm.ir.structural_equal(mod, partitioned_mod)