Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
[Test] Add tvm.testing.requires_libtorch (apache#12737)
Browse files Browse the repository at this point in the history
Create a specific test dependency to map to USE_LIBTORCH, which
is disabled by deafult, and is independent from torch being
installed on the underlying machine, so it causes problems in
machines that have torch installed but TVM is build with
USE_LIBTORCH OFF.

Mark tests.python.contrib.test_libtorch_ops.test_backend with
this new decorator.
  • Loading branch information
leandron authored and xinetzone committed Nov 25, 2022
1 parent d19aad6 commit 313c418
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/tvm/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,9 @@ def _any_gpu_exists():
# Mark a test as requiring Arm(R) Ethos(TM)-N to run
requires_ethosn = Feature("ethosn", "Arm(R) Ethos(TM)-N", cmake_flag="USE_ETHOSN")

# Mark a test as requiring libtorch to run
requires_libtorch = Feature("libtorch", "LibTorch", cmake_flag="USE_LIBTORCH")

# Mark a test as requiring Hexagon to run
requires_hexagon = Feature(
"hexagon",
Expand Down
2 changes: 2 additions & 0 deletions tests/python/contrib/test_libtorch_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import tvm.relay
from tvm.relay.op.contrib import torchop
from tvm.testing import requires_libtorch

import_torch_error = None

Expand All @@ -30,6 +31,7 @@


@pytest.mark.skipif(torch is None, reason=f"PyTorch is not available: {import_torch_error}")
@requires_libtorch
def test_backend():
@torch.jit.script
def script_fn(x, y):
Expand Down

0 comments on commit 313c418

Please sign in to comment.