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

(shortfin) Parameterized pytest fixtures for testing over cpu and gpu #599

Open
renxida opened this issue Nov 23, 2024 · 0 comments
Open

Comments

@renxida
Copy link
Contributor

renxida commented Nov 23, 2024

We should make better fixtures that would automatically replicate shortfin tests across CPU / GPU / multi-gpu / etc

Using this pytest hack:

# Dynamic Parameterization for lsys Fixture
def pytest_generate_tests(metafunc):
    if "generic_lsys" in metafunc.fixturenames:
        system = metafunc.config.getoption("--system")
        if system == "amdgpu":
            params = ["cpu", "amdgpu"]
        else:
            params = [system]
        metafunc.parametrize("generic_lsys", params, indirect=True)

We can make this fixture automatically test every test that uses it on not just CPU, but also GPU where available.

@pytest.fixture(scope="session")
def generic_lsys(request):
    system_type = request.param
    if system_type == "cpu" or system_type == "hostcpu":
        sc = sf.host.CPUSystemBuilder()
    elif system_type == "amdgpu":
        sc = sf.amdgpu.SystemBuilder()
    lsys = sc.create_system()
    yield lsys
    lsys.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant