Skip to content

Commit

Permalink
Option to setup compiler configurations using pytest arguments (#601)
Browse files Browse the repository at this point in the history
Fix #600
  • Loading branch information
nvukobratTT authored Nov 5, 2024
1 parent 8e76b59 commit 6171aed
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions forge/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from forge.verify.config import TestKind
from forge.torch_compile import reset_state

from forge.config import _get_global_compiler_config

collect_ignore = ["legacy_tests"]


Expand Down Expand Up @@ -98,6 +100,9 @@ def clear_forge():


def pytest_addoption(parser):
parser.addoption(
"--generate-op-tests", action="store_true", default=False, help="Generate op tests for the given model"
)
parser.addoption(
"--silicon-only", action="store_true", default=False, help="run silicon tests only, skip golden/model"
)
Expand Down Expand Up @@ -166,6 +171,25 @@ def runslow(request):
"""


@pytest.fixture(autouse=True, scope="session")
def initialize_global_compiler_configuration_based_on_pytest_args(pytestconfig):
"""
Set the global compiler config options for the test session
which will generate op tests for the given model.
"""
compiler_cfg = _get_global_compiler_config()

compiler_cfg.tvm_generate_op_tests = pytestconfig.getoption("--generate-op-tests")

if compiler_cfg.tvm_generate_op_tests:
# For running standalone tests, we need to retain the generated python files
# together with stored model parameters
compiler_cfg.retain_tvm_python_files = True

# Required to prevent early tensor deallocation
compiler_cfg.enable_op_level_comparision = True


@pytest.hookimpl(tryfirst=True)
def pytest_cmdline_preparse(config, args):

Expand Down

0 comments on commit 6171aed

Please sign in to comment.