Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
* Remove unused code
* Add negative test case

Change-Id: I5e12d070554954e320b4d15c02d5e2ada179fce5
  • Loading branch information
lhutton1 committed Nov 23, 2022
1 parent 5bbf543 commit c705665
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
12 changes: 0 additions & 12 deletions python/tvm/relay/op/contrib/ethosn.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ def is_inline_non_compute_intensive_partitions_enabled() -> bool:
return compiler_attrs.inline_non_compute_intensive_partitions


def is_experimental_compiler_enabled() -> bool:
"""
Determine whether the experimental compiler option is enabled.
Returns
-------
True if the experimental compiler is enabled, False if not.
"""
compiler_attrs = tvm.get_global_func("relay.ext.ethos-n.get_compiler_attrs")()
return compiler_attrs.experimental_compiler


def partition_for_ethosn(mod, params=None, **opts):
"""Partition the graph greedily offloading supported
operators to Arm Ethos-N NPU.
Expand Down
27 changes: 27 additions & 0 deletions tests/python/contrib/test_ethosn/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,30 @@ def test_experimental_compiler(capfd):
assert (
"WARNING: Experimental Compiler in use." in captured.err
), "Experimental compiler was not activated."


@requires_ethosn
def test_without_experimental_compiler(capfd):
"""Test compilation when the experimental compiler is not enabled."""
dtype = "int8"
input_shape = (1, 2, 2, 2)

x = relay.var("x", shape=input_shape, dtype=dtype)
y = relay.reshape(x, newshape=(1, 1, 1, 8))
mod = tei.make_ethosn_partition(y)

additional_config_args = {
"variant": "n78",
"experimental_compiler": False,
"inline_non_compute_intensive_partitions": False,
}

tei.build(mod, {}, True, additional_config_args=additional_config_args)

# Check for hints that the experimental compiler was activated.
# The support library logs a warning to say the the experimental
# compiler is in use. Check that this warning was logged.
captured = capfd.readouterr()
assert (
"WARNING: Experimental Compiler in use." not in captured.err
), "Experimental compiler was enabled when it is not expected to be."

0 comments on commit c705665

Please sign in to comment.