From 5e848b657cc133e740003a4469a0b52bc773a7cd Mon Sep 17 00:00:00 2001 From: Matthew Barrett Date: Thu, 26 Aug 2021 10:30:36 +0100 Subject: [PATCH] Fix import guards for tests Change-Id: Iaee06017bd125d3040ce42182c4ccdb80d7fc946 --- .../python/contrib/test_ethosu/test_attr_passing.py | 6 +++--- tests/python/contrib/test_ethosu/test_compiler.py | 5 ++++- .../contrib/test_ethosu/test_encode_constants.py | 4 ++-- .../contrib/test_ethosu/test_extract_constants.py | 6 ++++-- tests/python/contrib/test_ethosu/test_lower_to_te.py | 6 +++--- .../contrib/test_ethosu/test_replace_conv2d.py | 4 ++-- .../python/contrib/test_ethosu/test_replace_copy.py | 2 ++ tests/python/contrib/test_ethosu/test_scheduler.py | 12 ++++-------- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/python/contrib/test_ethosu/test_attr_passing.py b/tests/python/contrib/test_ethosu/test_attr_passing.py index 812f68513c31c..a2fbe1888d2aa 100644 --- a/tests/python/contrib/test_ethosu/test_attr_passing.py +++ b/tests/python/contrib/test_ethosu/test_attr_passing.py @@ -14,8 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# pylint: disable=invalid-name, unused-argument +import pytest +pytest.importorskip("ethosu.vela") import tvm from tvm import relay from tvm.relay.backend.contrib.ethosu import util @@ -40,5 +41,4 @@ def test_compiler_attr_default(): if __name__ == "__main__": - test_compiler_attr() - test_compiler_attr_default() + pytest.main([__file__]) diff --git a/tests/python/contrib/test_ethosu/test_compiler.py b/tests/python/contrib/test_ethosu/test_compiler.py index ae649c6beeacd..4df6311a230c7 100644 --- a/tests/python/contrib/test_ethosu/test_compiler.py +++ b/tests/python/contrib/test_ethosu/test_compiler.py @@ -14,6 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import pytest + +pytest.importorskip("ethosu.vela") import tvm from tvm import relay from tvm.relay.backend.contrib.ethosu.tir.compiler import lower_to_tir @@ -42,4 +45,4 @@ def test_lower_to_tir(): if __name__ == "__main__": - test_lower_to_tir() + pytest.main([__file__]) diff --git a/tests/python/contrib/test_ethosu/test_encode_constants.py b/tests/python/contrib/test_ethosu/test_encode_constants.py index 3a3c4b5913cc8..0e546ae2fd24f 100644 --- a/tests/python/contrib/test_ethosu/test_encode_constants.py +++ b/tests/python/contrib/test_ethosu/test_encode_constants.py @@ -14,8 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -import numpy as np +import pytest +pytest.importorskip("ethosu.vela") import tvm from tvm import tir from tvm import script @@ -24,7 +25,6 @@ from tvm.relay.testing import run_opt_pass from tvm.relay.backend.contrib.ethosu.tir.compiler import lower_to_tir from tvm.relay.backend.contrib.ethosu.tir.scheduler import Convolution2DCompute -import pytest from infra import make_ethosu_conv2d diff --git a/tests/python/contrib/test_ethosu/test_extract_constants.py b/tests/python/contrib/test_ethosu/test_extract_constants.py index 48266b54a6052..98094d8a4ed41 100644 --- a/tests/python/contrib/test_ethosu/test_extract_constants.py +++ b/tests/python/contrib/test_ethosu/test_extract_constants.py @@ -14,6 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import pytest + +pytest.importorskip("ethosu.vela") import tvm from tvm import relay from tvm.relay.testing import run_opt_pass @@ -93,5 +96,4 @@ def _expected(): if __name__ == "__main__": - test_extract_constants_single() - test_extract_constants_multi() + pytest.main([__file__]) diff --git a/tests/python/contrib/test_ethosu/test_lower_to_te.py b/tests/python/contrib/test_ethosu/test_lower_to_te.py index 18bde7ebd7c03..cabd68b4e8d26 100644 --- a/tests/python/contrib/test_ethosu/test_lower_to_te.py +++ b/tests/python/contrib/test_ethosu/test_lower_to_te.py @@ -14,11 +14,11 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# pylint: disable=invalid-name, unused-argument +import pytest +pytest.importorskip("ethosu.vela") import tvm from tvm import relay -from tvm.relay.testing import run_opt_pass from tvm.relay.backend.contrib.ethosu.tir.compiler import lower_to_te from tvm.relay.backend.contrib.ethosu.tir.scheduler import Convolution2DCompute import tvm.relay.backend.contrib.ethosu.op as ethosu_ops @@ -60,4 +60,4 @@ def test_ethosu_conv2d(): if __name__ == "__main__": - test_ethosu_conv2d() + pytest.main([__file__]) diff --git a/tests/python/contrib/test_ethosu/test_replace_conv2d.py b/tests/python/contrib/test_ethosu/test_replace_conv2d.py index 382260fd53e01..96fe56d1778ef 100644 --- a/tests/python/contrib/test_ethosu/test_replace_conv2d.py +++ b/tests/python/contrib/test_ethosu/test_replace_conv2d.py @@ -14,7 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import pytest +pytest.importorskip("ethosu.vela") import tvm import tvm.script from tvm.script import tir, ty @@ -24,8 +26,6 @@ from tvm.relay.backend.contrib.ethosu.tir.scheduler import total_cascader from infra import make_ethosu_conv2d, get_convolutional_args -import pytest - @pytest.mark.parametrize( "trial", diff --git a/tests/python/contrib/test_ethosu/test_replace_copy.py b/tests/python/contrib/test_ethosu/test_replace_copy.py index afa9b8e74ca33..222dccacc9062 100644 --- a/tests/python/contrib/test_ethosu/test_replace_copy.py +++ b/tests/python/contrib/test_ethosu/test_replace_copy.py @@ -15,6 +15,8 @@ # specific language governing permissions and limitations # under the License. import pytest + +pytest.importorskip("ethosu.vela") import tvm import tvm.script from tvm.script import tir, ty diff --git a/tests/python/contrib/test_ethosu/test_scheduler.py b/tests/python/contrib/test_ethosu/test_scheduler.py index bef665fe2444a..b07f8ea7f48b2 100644 --- a/tests/python/contrib/test_ethosu/test_scheduler.py +++ b/tests/python/contrib/test_ethosu/test_scheduler.py @@ -14,7 +14,9 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -import tvm +import pytest + +pytest.importorskip("ethosu.vela") from tvm import relay from tvm.relay.testing import run_opt_pass from tvm import te, topi @@ -139,10 +141,4 @@ def test_schedule_cache_reads(): if __name__ == "__main__": - test_tile_nd() - test_schedule_pragmas() - test_schedule_pragmas_for_const() - test_inline_no_ops() - test_total_cascader() - test_copy_constants() - test_schedule_cache_reads() + pytest.main([__file__])