Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE]: torch.compile test functions #162

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions torch_np/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,14 @@ def pytest_collection_modifyitems(config, items):
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)


import torch

def pytest_runtest_call(item):
compiled = torch.compile(item.function)
# smoke test the compiled test
compiled(item, **item.funcargs) # the 1st argument is a placeholder

# run the original, non-compiled test
item.runtest()
4 changes: 2 additions & 2 deletions torch_np/tests/numpy_tests/core/test_dlpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import torch

import torch_np as np
from torch_np.testing import assert_array_equal
import numpy as np
from numpy.testing import assert_array_equal

IS_PYPY = False

Expand Down
8 changes: 6 additions & 2 deletions torch_np/tests/numpy_tests/core/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import types
from typing import Any

import torch_np as np
from torch_np.testing import (assert_, assert_equal, assert_array_equal)
#import torch_np as np
#from torch_np.testing import (assert_, assert_equal, assert_array_equal)

import numpy as np
from numpy.testing import (assert_, assert_equal, assert_array_equal)

from pytest import raises as assert_raises

import pickle
Expand Down
4 changes: 2 additions & 2 deletions torch_np/tests/numpy_tests/core/test_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from pytest import raises as assert_raises

import torch_np as np
from torch_np.testing import (
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_almost_equal,
suppress_warnings, assert_raises_regex, assert_allclose
)
Expand Down
4 changes: 2 additions & 2 deletions torch_np/tests/numpy_tests/core/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import pytest
from pytest import raises as assert_raises

import torch_np as np
import numpy as np
# from numpy.core._multiarray_tests import array_indexing # numpy implements this in C
from itertools import product
from torch_np.testing import (
from numpy.testing import (
assert_, assert_equal, assert_raises_regex,
assert_array_equal, assert_warns, HAS_REFCOUNT, IS_WASM
)
Expand Down
4 changes: 2 additions & 2 deletions torch_np/tests/numpy_tests/core/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from decimal import Decimal
import mmap

import torch_np as np
import numpy as np

import numpy.core._multiarray_tests as _multiarray_tests
#from numpy.core._rational_tests import rational

from torch_np.testing import (
from numpy.testing import (
assert_, assert_warns, assert_equal, assert_almost_equal,
assert_array_equal, assert_raises_regex, assert_array_almost_equal,
assert_allclose, # IS_PYPY, IS_PYSTON, HAS_REFCOUNT,
Expand Down