MCPcopy Create free account
hub / github.com/apache/tvm / _auto_parametrize_target

Function _auto_parametrize_target

python/tvm/testing/plugin.py:106–141  ·  view source on GitHub ↗

Automatically applies parametrize_targets Used if a test function uses the "target" fixture, but isn't already marked with @tvm.testing.parametrize_targets. Intended for use in the pytest_generate_tests() handler of a conftest.py file.

(metafunc)

Source from the content-addressed store, hash-verified

104
105
106def _auto_parametrize_target(metafunc):
107 """Automatically applies parametrize_targets
108
109 Used if a test function uses the "target" fixture, but isn't
110 already marked with @tvm.testing.parametrize_targets. Intended
111 for use in the pytest_generate_tests() handler of a conftest.py
112 file.
113
114 """
115
116 if "target" in metafunc.fixturenames:
117 # Check if any explicit parametrizations exist, and apply one
118 # if they do not. If the function is marked with either
119 # excluded or known failing targets, use these to determine
120 # the targets to be used.
121 parametrized_args = [
122 arg.strip()
123 for mark in metafunc.definition.iter_markers("parametrize")
124 for arg in mark.args[0].split(",")
125 ]
126 if "target" not in parametrized_args:
127 excluded_targets = getattr(metafunc.function, "tvm_excluded_targets", [])
128
129 # Add a parametrize marker instead of calling
130 # metafunc.parametrize so that the parametrize rewriting
131 # can still occur.
132 mark = pytest.mark.parametrize(
133 "target",
134 [
135 t["target"]
136 for t in utils._get_targets()
137 if t["target_kind"] not in excluded_targets
138 ],
139 scope="session",
140 )
141 metafunc.definition.add_marker(mark)
142
143
144def _add_target_specific_marks(metafunc):

Callers 1

pytest_generate_testsFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…