This is an automated email from the ASF dual-hosted git repository.
leandron 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 cfb5674c25 [ETHOSN] Remove remaining support for the N77 variant
(#11262)
cfb5674c25 is described below
commit cfb5674c25021f0552ce4162e256ac67005d94d6
Author: Luke Hutton <[email protected]>
AuthorDate: Wed May 11 09:57:15 2022 +0100
[ETHOSN] Remove remaining support for the N77 variant (#11262)
Specifically removes some TVMC tests that are no longer necessary
and some partitioning infrastructure.
---
python/tvm/driver/tvmc/composite_target.py | 5 ---
python/tvm/relay/op/contrib/ethosn.py | 40 -----------------
.../contrib/test_ethosn/test_partition_params.py | 50 ----------------------
tests/python/driver/tvmc/test_compiler.py | 18 --------
tests/python/driver/tvmc/test_composite_target.py | 1 -
tests/python/driver/tvmc/test_target.py | 15 -------
6 files changed, 129 deletions(-)
diff --git a/python/tvm/driver/tvmc/composite_target.py
b/python/tvm/driver/tvmc/composite_target.py
index 3b5ba9ddaa..de743799f0 100644
--- a/python/tvm/driver/tvmc/composite_target.py
+++ b/python/tvm/driver/tvmc/composite_target.py
@@ -23,7 +23,6 @@ import logging
import tvm.contrib.target.vitis_ai # pylint: disable=unused-import
from tvm.relay.op.contrib.arm_compute_lib import partition_for_arm_compute_lib
-from tvm.relay.op.contrib.ethosn import partition_for_ethosn77
from tvm.relay.op.contrib.ethosn import partition_for_ethosn78
from tvm.relay.op.contrib.cmsisnn import partition_for_cmsisnn
from tvm.relay.op.contrib.ethosu import partition_for_ethosu
@@ -56,10 +55,6 @@ REGISTERED_CODEGEN = {
"config_key": "relay.ext.cmsisnn.options",
"pass_pipeline": partition_for_cmsisnn,
},
- "ethos-n77": {
- "config_key": "relay.ext.ethos-n.options",
- "pass_pipeline": partition_for_ethosn77,
- },
"ethos-n78": {
"config_key": "relay.ext.ethos-n.options",
"pass_pipeline": partition_for_ethosn78,
diff --git a/python/tvm/relay/op/contrib/ethosn.py
b/python/tvm/relay/op/contrib/ethosn.py
index 9ebef0fac8..312bc874f1 100644
--- a/python/tvm/relay/op/contrib/ethosn.py
+++ b/python/tvm/relay/op/contrib/ethosn.py
@@ -46,46 +46,6 @@ def ethosn_available():
return Available.SW_AND_HW if hw else Available.SW_ONLY
-def partition_for_ethosn77(mod, params=None, **opts):
- """Partition the graph greedily offloading supported
- operators to Arm Ethos-N NPU.
-
- Parameters
- ----------
- mod : Module
- The module to run passes on.
- params : Optional[Dict[str, NDArray]]
- Constant input parameters.
-
- Returns
- -------
- ret : annotated and partitioned module.
- """
- if opts:
- tops = opts.get("tops", None)
- ple_ratio = opts.get("ple_ratio", None)
- sram_size = opts.get("sram_size", None)
- if tops or ple_ratio or sram_size:
- raise ValueError(
- "Setting tops, ple_ratio or sram_size has no effect when
targeting Ethos(TM)-N77"
- )
-
- if params:
- mod["main"] = bind_params_by_name(mod["main"], params)
-
- seq = tvm.transform.Sequential(
- [
- transform.InferType(),
- transform.MergeComposite(pattern_table()),
- transform.AnnotateTarget("ethos-n"),
- transform.MergeCompilerRegions(),
- transform.PartitionGraph(),
- ]
- )
-
- return seq(mod)
-
-
def partition_for_ethosn78(mod, params=None, **opts):
"""Partition the graph greedily offloading supported
operators to Arm Ethos-N NPU.
diff --git a/tests/python/contrib/test_ethosn/test_partition_params.py
b/tests/python/contrib/test_ethosn/test_partition_params.py
index 97f8e50a7d..174bdd9416 100644
--- a/tests/python/contrib/test_ethosn/test_partition_params.py
+++ b/tests/python/contrib/test_ethosn/test_partition_params.py
@@ -22,7 +22,6 @@ import tvm
from tvm import relay
import numpy as np
-from tvm.relay.op.contrib.ethosn import partition_for_ethosn77
from tvm.relay.op.contrib.ethosn import partition_for_ethosn78
from tvm.testing import requires_ethosn
@@ -73,52 +72,3 @@ def test_ethosn78_partition_invalid_variant():
mod = tvm.IRModule.from_expr(res)
opts = {"variant": "Ethos-N"}
partition_for_ethosn78(mod, **opts)
-
-
-@requires_ethosn
-def test_ethosn78_partition_error():
- with pytest.raises(
- ValueError, match=r".*When targeting Ethos\(TM\)-N78,
-variant=Ethos-N78 should be set.*"
- ):
- a = relay.var("a", shape=[2, 7, 8, 8], dtype="uint8")
- w = relay.const(np.random.uniform(-10, 10, (8, 7, 3,
3)).astype("uint8"))
- res = relay.nn.conv2d(
- a, w, kernel_size=(3, 3), padding=(1, 1), channels=8,
out_dtype="uint8"
- )
- b = relay.var("b", shape=[8], dtype="uint8")
- res = relay.nn.bias_add(res, b, axis=1)
-
- mod = tvm.IRModule.from_expr(res)
- opts = {"variant": "Ethos-N77"}
- partition_for_ethosn78(mod, **opts)
-
-
-@requires_ethosn
-def test_ethosn77_partition_no_error():
- a = relay.var("a", shape=[2, 7, 8, 8], dtype="uint8")
- w = relay.const(np.random.uniform(-10, 10, (8, 7, 3, 3)).astype("uint8"))
- res = relay.nn.conv2d(a, w, kernel_size=(3, 3), padding=(1, 1),
channels=8, out_dtype="uint8")
- b = relay.var("b", shape=[8], dtype="uint8")
- res = relay.nn.bias_add(res, b, axis=1)
-
- mod = tvm.IRModule.from_expr(res)
- partition_for_ethosn77(mod)
-
-
-@requires_ethosn
-def test_ethosn77_partition_error():
- with pytest.raises(
- ValueError,
- match=r".*Setting tops, ple_ratio or sram_size has no effect when
targeting Ethos\(TM\)-N77.*",
- ):
- a = relay.var("a", shape=[2, 7, 8, 8], dtype="uint8")
- w = relay.const(np.random.uniform(-10, 10, (8, 7, 3,
3)).astype("uint8"))
- res = relay.nn.conv2d(
- a, w, kernel_size=(3, 3), padding=(1, 1), channels=8,
out_dtype="uint8"
- )
- b = relay.var("b", shape=[8], dtype="uint8")
- res = relay.nn.bias_add(res, b, axis=1)
-
- mod = tvm.IRModule.from_expr(res)
- opts = {"tops": 4}
- partition_for_ethosn77(mod, **opts)
diff --git a/tests/python/driver/tvmc/test_compiler.py
b/tests/python/driver/tvmc/test_compiler.py
index bd783b00fa..2acb179735 100644
--- a/tests/python/driver/tvmc/test_compiler.py
+++ b/tests/python/driver/tvmc/test_compiler.py
@@ -378,24 +378,6 @@ def test_compile_opencl(tflite_mobilenet_v1_0_25_128):
assert os.path.exists(dumps_path)
[email protected](
- not ethosn_available(),
- reason="--target=Ethos(TM)-N78 is not available. TVM built with
'USE_ETHOSN OFF'",
-)
-def
test_compile_tflite_module_with_external_codegen_ethos_n77(tflite_mobilenet_v1_1_quant):
- pytest.importorskip("tflite")
- tvmc_model = tvmc.load(tflite_mobilenet_v1_1_quant)
- tvmc_package = tvmc.compile(tvmc_model, target="ethos-n77, llvm",
dump_code="relay")
- dumps_path = tvmc_package.package_path + ".relay"
-
- # check for output types
- assert type(tvmc_package) is TVMCPackage
- assert type(tvmc_package.graph) is str
- assert type(tvmc_package.lib_path) is str
- assert type(tvmc_package.params) is bytearray
- assert os.path.exists(dumps_path)
-
-
@tvm.testing.requires_cmsisnn
def test_compile_tflite_module_with_external_codegen_cmsisnn(
tmpdir_factory, tflite_cnn_s_quantized
diff --git a/tests/python/driver/tvmc/test_composite_target.py
b/tests/python/driver/tvmc/test_composite_target.py
index dfaf30c9e2..d0893af7c1 100644
--- a/tests/python/driver/tvmc/test_composite_target.py
+++ b/tests/python/driver/tvmc/test_composite_target.py
@@ -33,7 +33,6 @@ from tvm.driver.tvmc import TVMCException
def test_get_codegen_names():
names = tvmc.composite_target.get_codegen_names()
- assert "ethos-n77" in names
assert "ethos-n78" in names
assert "vitis-ai" in names
assert len(names) > 0
diff --git a/tests/python/driver/tvmc/test_target.py
b/tests/python/driver/tvmc/test_target.py
index b02f89d2e4..eb3ffdea42 100644
--- a/tests/python/driver/tvmc/test_target.py
+++ b/tests/python/driver/tvmc/test_target.py
@@ -35,11 +35,6 @@ def test_target_from_cli__error_target_not_found():
_ = target_from_cli("invalidtarget")
-def test_target_from_cli__error_no_tvm_target():
- with pytest.raises(TVMCException):
- _ = target_from_cli("ethos-n77")
-
-
def test_target_two_tvm_targets():
tvm_target, extra_targets = target_from_cli(
"opencl -device=mali, llvm -mtriple=aarch64-linux-gnu"
@@ -157,16 +152,6 @@ def test_parse_quotes_and_separators_on_options():
assert "+v1.0x,+value" == targets_double_quote[0]["opts"]["option1"]
-def test_parse_multiple_target_with_opts_ethos_n77():
- targets = parse_target("ethos-n77 -myopt=value, llvm -device=arm_cpu
--system-lib")
-
- assert len(targets) == 2
- assert "ethos-n77" == targets[0]["name"]
- assert "myopt" in targets[0]["opts"]
- assert "value" == targets[0]["opts"]["myopt"]
- assert "llvm" == targets[1]["name"]
-
-
def test_parse_multiple_target_with_opts_ethos_n78():
targets = parse_target("ethos-n78 -myopt=value, llvm -device=arm_cpu
--system-lib")