Skip to content

Commit

Permalink
Enable timm tests (#276)
Browse files Browse the repository at this point in the history
### Ticket
#267 

### Problem description
- timm image classification tests were previously disabled due to
existing errors

### What's changed
- This test fixes the pytest-related errors and enables the test
- Port manage_dependencies test fixture from the pytorch2.0_ttnn repo
([ref](https://github.com/tenstorrent/pytorch2.0_ttnn/blob/20f557b3bc5736c70c4eb85a6e77139f3e96b301/tests/conftest.py#L271-L278))
- Change self.**model** field naming to use newer naming
self.**framework_model**
- However, I note that these tests do not pass due to various tensor
shape mismatches. This change only enables them to run.

### Checklist
- [x] New/Existing tests provide coverage for changes (This enables a
test)
  • Loading branch information
jameszianxuTT authored Feb 5, 2025
1 parent 7bab2e9 commit f112449
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest
import torch
import subprocess
import sys


@pytest.fixture(autouse=True)
Expand All @@ -13,6 +15,18 @@ def run_around_tests():
torch._dynamo.reset()


@pytest.fixture(scope="module")
def manage_dependencies(request):
dependencies = getattr(request.module, "dependencies", [])
# Install dependencies
subprocess.check_call([sys.executable, "-m", "pip", "install"] + dependencies)
yield
# Uninstall dependencies
subprocess.check_call(
[sys.executable, "-m", "pip", "uninstall", "-y"] + dependencies
)


def pytest_addoption(parser):
parser.addoption(
"--op_by_op",
Expand Down
3 changes: 1 addition & 2 deletions tests/models/timm/test_timm_image_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _load_inputs(self):
)
)
# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(self.model)
data_config = timm.data.resolve_model_data_config(self.framework_model)
transforms = timm.data.create_transform(**data_config, is_training=False)
input_batch = transforms(img).unsqueeze(
0
Expand Down Expand Up @@ -104,7 +104,6 @@ def _load_inputs(self):
]


@pytest.mark.skip # skipped due to missing manage_dependencies package
@pytest.mark.usefixtures("manage_dependencies")
@pytest.mark.parametrize("model_and_mode", model_and_mode_list)
@pytest.mark.parametrize("op_by_op", [True, False], ids=["op_by_op", "full"])
Expand Down

0 comments on commit f112449

Please sign in to comment.