mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[Code Clean] Remove deadcodes about Python3.9 [8/N] (#163728)
As the title stated. Pull Request resolved: https://github.com/pytorch/pytorch/pull/163728 Approved by: https://github.com/albanD, https://github.com/cyyever ghstack dependencies: #163626, #163627, #163629, #163643, #163644, #163645, #163646
This commit is contained in:
@ -80,7 +80,7 @@ def fn():
|
||||
self.assertEqual(fn.__code__.co_lnotab, result[1].co_lnotab)
|
||||
|
||||
@unittest.skipIf(
|
||||
sys.version_info < (3, 10) or sys.version_info >= (3, 11),
|
||||
sys.version_info >= (3, 11),
|
||||
"linetable test for Python 3.10",
|
||||
)
|
||||
def test_linetable_310_writer(self):
|
||||
@ -95,19 +95,6 @@ def fn():
|
||||
result = bytecode_transformation.assemble(inst, fn.__code__.co_firstlineno)
|
||||
self.assertTrue(result[1] == fn.__code__.co_linetable)
|
||||
|
||||
@unittest.skipIf(sys.version_info >= (3, 10), "use lnotab when python < 3.10")
|
||||
def test_lnotab_writer(self):
|
||||
def fn():
|
||||
a = 10
|
||||
b = 20
|
||||
c = a + b
|
||||
f = "lnotab_writer"
|
||||
return f"Test if {f} generates correct co_lnotab: {c}"
|
||||
|
||||
inst = dis.get_instructions(fn)
|
||||
result = bytecode_transformation.assemble(inst, fn.__code__.co_firstlineno)
|
||||
self.assertTrue(result[1] == fn.__code__.co_lnotab)
|
||||
|
||||
def test_if_tensor_is_none(self):
|
||||
"""
|
||||
Python 3.11 adds new jump instructions that check if
|
||||
|
@ -410,10 +410,6 @@ class FunctionTests(torch._dynamo.test_case.TestCase):
|
||||
combs.append(torch.ones(size))
|
||||
return combs
|
||||
|
||||
@unittest.skipIf(
|
||||
sys.version_info < (3, 10),
|
||||
"itertools.pairwise was added at Python 3.10",
|
||||
)
|
||||
@make_test
|
||||
def test_itertools_pairwise(a):
|
||||
pairs = []
|
||||
@ -4698,10 +4694,6 @@ class DefaultsTests(torch._dynamo.test_case.TestCase):
|
||||
self.assertEqual(len(lst), 2)
|
||||
self.assertEqual(lst[0], lst[1])
|
||||
|
||||
@unittest.skipIf(
|
||||
sys.version_info < (3, 10),
|
||||
"zip strict kwargs not implemented for Python < 3.10",
|
||||
)
|
||||
def test_zip_strict(self):
|
||||
def fn(x, ys, zs):
|
||||
x = x.clone()
|
||||
|
@ -1,6 +1,5 @@
|
||||
# Owner(s): ["module: dynamo"]
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from typing import Literal
|
||||
from unittest.mock import MagicMock, patch
|
||||
@ -45,7 +44,6 @@ def create_simple_test_model_gpu():
|
||||
|
||||
|
||||
class TestConfigFuzzer(TestCase):
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_sampling_method_toggle(self):
|
||||
toggle = SamplingMethod.dispatch(SamplingMethod.TOGGLE)
|
||||
self.assertEqual(toggle("", bool, False), True)
|
||||
@ -55,26 +53,22 @@ class TestConfigFuzzer(TestCase):
|
||||
self.assertTrue("bar" in toggle("", list[Literal["foo", "bar"]], ["foo"]))
|
||||
self.assertTrue("foo" in toggle("", list[Literal["foo", "bar"]], ["bar"]))
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_sampling_method_random(self):
|
||||
random = SamplingMethod.dispatch(SamplingMethod.RANDOM)
|
||||
samp = [random("", bool, False) for i in range(1000)]
|
||||
self.assertTrue(not all(samp))
|
||||
|
||||
@unittest.skipIf(not HAS_GPU, "requires gpu")
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_inductor_gpu(self):
|
||||
fuzzer = ConfigFuzzer(inductor_config, create_simple_test_model_gpu, seed=30)
|
||||
self.assertIsNotNone(fuzzer.default)
|
||||
fuzzer.reproduce([{"max_fusion_size": 1}])
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_inductor_cpu(self):
|
||||
fuzzer = ConfigFuzzer(inductor_config, create_simple_test_model_cpu, seed=100)
|
||||
self.assertIsNotNone(fuzzer.default)
|
||||
fuzzer.reproduce([{"max_fusion_size": 1}])
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_bisector_exception(self):
|
||||
key_1 = {"e_bool": False, "e_optional": None}
|
||||
|
||||
@ -95,7 +89,6 @@ class TestConfigFuzzer(TestCase):
|
||||
for res in results:
|
||||
self.assertEqual(res, key_1)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_bisector_boolean(self):
|
||||
key_1 = {"e_bool": False, "e_optional": None}
|
||||
|
||||
@ -114,7 +107,6 @@ class TestConfigFuzzer(TestCase):
|
||||
for res in results:
|
||||
self.assertEqual(res, key_1)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_n_tuple(self):
|
||||
key_1 = {"e_bool": False, "e_optional": None}
|
||||
|
||||
@ -132,7 +124,6 @@ class TestConfigFuzzer(TestCase):
|
||||
self.assertEqual(results.num_ran(), max_combo)
|
||||
self.assertEqual(results.lookup(tuple(key_1.keys())), Status.FAILED_RUN_RETURN)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_config_fuzzer_inductor_bisect(self):
|
||||
# these values just chosen randomly, change to different ones if necessary
|
||||
key_1 = {"split_reductions": False, "compute_all_bounds": True}
|
||||
@ -163,7 +154,6 @@ class TestConfigFuzzer(TestCase):
|
||||
- set(MODULE_DEFAULTS["torch._inductor.config"].keys()),
|
||||
)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
@unittest.skipIf(not IS_LINUX, "PerfCounters are only supported on Linux")
|
||||
def test_config_fuzzer_dynamo_bisect(self):
|
||||
# these values just chosen randomly, change to different ones if necessary
|
||||
@ -195,7 +185,6 @@ class TestConfigFuzzer(TestCase):
|
||||
- set(MODULE_DEFAULTS["torch._dynamo.config"].keys()),
|
||||
)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
@patch("torch.compile")
|
||||
def test_fuzzer_inductor_calling_compile(self, compile):
|
||||
def create_key_1():
|
||||
@ -209,7 +198,6 @@ class TestConfigFuzzer(TestCase):
|
||||
fuzzer.bisect(num_attempts=num_attempts, p=0.5)
|
||||
self.assertEqual(compile.call_count, num_attempts)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 10), "python < 3.10 not supported")
|
||||
def test_fuzzer_running_test(self):
|
||||
def create_key_1():
|
||||
def myfn():
|
||||
|
@ -3785,25 +3785,6 @@ class TestFX(JitTestCase):
|
||||
|
||||
FileCheck().check("Tuple[()]").check("Tuple[str, Tuple[()]]").run(scripted.code)
|
||||
|
||||
@unittest.skipIf(
|
||||
IS_WINDOWS, "Python Windows bug? https://bugs.python.org/issue45108"
|
||||
)
|
||||
@unittest.skipIf(sys.version_info >= (3, 10), "Does not work on Python-3.10")
|
||||
def test_assert(self):
|
||||
def f(x):
|
||||
assert x > 1
|
||||
return x + 1
|
||||
|
||||
try:
|
||||
torch.fx.proxy.TracerBase.trace_asserts = True
|
||||
traced = symbolic_trace(f)
|
||||
finally:
|
||||
torch.fx.proxy.TracerBase.trace_asserts = False
|
||||
|
||||
self.assertEqual(f(2), traced(2))
|
||||
with self.assertRaises(AssertionError):
|
||||
traced(0)
|
||||
|
||||
def test_pytree(self):
|
||||
# Used to test that you can use your own placeholder class
|
||||
class PHTest(PHBase):
|
||||
@ -4819,7 +4800,6 @@ class TestFunctionalTracing(JitTestCase):
|
||||
def functional_test(self):
|
||||
if (
|
||||
func_name in self.UNTRACEABLE_FUNCTIONALS_PY38
|
||||
and sys.version_info >= (3, 8)
|
||||
and sys.version_info < (3, 12)
|
||||
):
|
||||
exc, err = self.UNTRACEABLE_FUNCTIONALS_PY38[func_name]
|
||||
|
@ -7375,7 +7375,7 @@ a")
|
||||
if "annotate" in li and "dtype" not in option:
|
||||
continue
|
||||
# Skip unsigned tensor initialization for signed values on 3.10
|
||||
if sys.version_info[:2] >= (3, 10) and "torch.uint8" in option and "-" in li:
|
||||
if "torch.uint8" in option and "-" in li:
|
||||
continue
|
||||
code = tensor_template.format(list_create=li, tensor_op=op, options=option)
|
||||
scope = {}
|
||||
|
@ -8,7 +8,7 @@ import warnings
|
||||
|
||||
MIN_CUDA_VERSION = "11.6"
|
||||
MIN_ROCM_VERSION = "5.4"
|
||||
MIN_PYTHON_VERSION = (3, 8)
|
||||
MIN_PYTHON_VERSION = (3, 10)
|
||||
|
||||
|
||||
class VerifyDynamoError(BaseException):
|
||||
|
Reference in New Issue
Block a user