mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[3/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torchgen (#127124)
The `usort` config in `pyproject.toml` has no effect due to a typo. Fixing the typo make `usort` do more and generate the changes in the PR. Except `pyproject.toml`, all changes are generated by `lintrunner -a --take UFMT --all-files`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/127124 Approved by: https://github.com/Skylion007 ghstack dependencies: #127122, #127123
This commit is contained in:
parent
0dae2ba5bd
commit
35ea5c6b22
|
|
@ -4,6 +4,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch._prims as prims
|
import torch._prims as prims
|
||||||
|
|
||||||
from torchgen.gen import parse_native_yaml
|
from torchgen.gen import parse_native_yaml
|
||||||
|
|
||||||
ROOT = Path(__file__).absolute().parent.parent.parent.parent
|
ROOT = Path(__file__).absolute().parent.parent.parent.parent
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ target-version = ["py38", "py39", "py310", "py311"]
|
||||||
|
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
src_paths = ["caffe2", "torch", "torchgen", "functorch", "tests"]
|
src_paths = ["caffe2", "torch", "torchgen", "functorch", "test"]
|
||||||
extra_standard_library = ["typing_extensions"]
|
extra_standard_library = ["typing_extensions"]
|
||||||
skip_gitignore = true
|
skip_gitignore = true
|
||||||
skip_glob = ["third_party/*"]
|
skip_glob = ["third_party/*"]
|
||||||
|
|
@ -34,11 +34,11 @@ include_trailing_comma = true
|
||||||
|
|
||||||
|
|
||||||
[tool.usort.known]
|
[tool.usort.known]
|
||||||
first_party = ["caffe2"]
|
first_party = ["caffe2", "torchgen", "test"]
|
||||||
standard_library = ["typing_extensions"]
|
standard_library = ["typing_extensions"]
|
||||||
|
|
||||||
[tool.usort.kown]
|
[tool.usort.kown]
|
||||||
first_party = ["torch", "torchgen", "functorch", "tests"]
|
first_party = ["torch", "functorch"]
|
||||||
|
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
# Owner(s): ["oncall: mobile"]
|
# Owner(s): ["oncall: mobile"]
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from test.jit.fixtures_srcs.generate_models import ALL_MODULES
|
|
||||||
from torch.testing._internal.common_utils import run_tests, TestCase
|
from torch.testing._internal.common_utils import run_tests, TestCase
|
||||||
|
|
||||||
|
from test.jit.fixtures_srcs.generate_models import ALL_MODULES
|
||||||
|
|
||||||
|
|
||||||
class TestUpgraderModelGeneration(TestCase):
|
class TestUpgraderModelGeneration(TestCase):
|
||||||
def test_all_modules(self):
|
def test_all_modules(self):
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ from collections import defaultdict
|
||||||
from typing import Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple
|
from typing import Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from torchgen.api import cpp
|
from torchgen.api import cpp
|
||||||
from torchgen.api.python import (
|
from torchgen.api.python import (
|
||||||
arg_parser_output_exprs,
|
arg_parser_output_exprs,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from collections import defaultdict
|
||||||
from typing import Any, Counter, Dict, List, Match, Optional, Sequence, Set, Tuple
|
from typing import Any, Counter, Dict, List, Match, Optional, Sequence, Set, Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from torchgen.api import cpp
|
from torchgen.api import cpp
|
||||||
|
|
||||||
from torchgen.api.autograd import (
|
from torchgen.api.autograd import (
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from gen_op_registration_allowlist import (
|
||||||
gen_transitive_closure,
|
gen_transitive_closure,
|
||||||
load_op_dep_graph,
|
load_op_dep_graph,
|
||||||
)
|
)
|
||||||
|
|
||||||
from torchgen.selective_build.operator import (
|
from torchgen.selective_build.operator import (
|
||||||
merge_operator_dicts,
|
merge_operator_dicts,
|
||||||
SelectiveBuildOperator,
|
SelectiveBuildOperator,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import yaml
|
||||||
from tools.lite_interpreter.gen_selected_mobile_ops_header import (
|
from tools.lite_interpreter.gen_selected_mobile_ops_header import (
|
||||||
write_selected_mobile_ops,
|
write_selected_mobile_ops,
|
||||||
)
|
)
|
||||||
|
|
||||||
from torchgen.selective_build.selector import (
|
from torchgen.selective_build.selector import (
|
||||||
combine_selective_builders,
|
combine_selective_builders,
|
||||||
SelectiveBuilder,
|
SelectiveBuilder,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import os
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from torchgen.code_template import CodeTemplate
|
from torchgen.code_template import CodeTemplate
|
||||||
from torchgen.selective_build.selector import SelectiveBuilder
|
from torchgen.selective_build.selector import SelectiveBuilder
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@ from typing import Dict, List, Sequence
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
|
|
||||||
|
from tools.autograd.gen_python_functions import (
|
||||||
|
group_overloads,
|
||||||
|
load_signatures,
|
||||||
|
should_generate_py_binding,
|
||||||
|
)
|
||||||
|
|
||||||
from torchgen.api.python import (
|
from torchgen.api.python import (
|
||||||
PythonSignatureGroup,
|
PythonSignatureGroup,
|
||||||
PythonSignatureNativeFunctionPair,
|
PythonSignatureNativeFunctionPair,
|
||||||
|
|
@ -18,12 +24,6 @@ from torchgen.gen import parse_native_yaml, parse_tags_yaml
|
||||||
from torchgen.model import _TorchDispatchModeKey, DispatchKey, Variant
|
from torchgen.model import _TorchDispatchModeKey, DispatchKey, Variant
|
||||||
from torchgen.utils import FileManager
|
from torchgen.utils import FileManager
|
||||||
|
|
||||||
from tools.autograd.gen_python_functions import (
|
|
||||||
group_overloads,
|
|
||||||
load_signatures,
|
|
||||||
should_generate_py_binding,
|
|
||||||
)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This module implements generation of type stubs for PyTorch,
|
This module implements generation of type stubs for PyTorch,
|
||||||
enabling use of autocomplete in IDEs like PyCharm, which otherwise
|
enabling use of autocomplete in IDEs like PyCharm, which otherwise
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,9 @@ def generate_code(
|
||||||
force_schema_registration: bool = False,
|
force_schema_registration: bool = False,
|
||||||
operator_selector: Any = None,
|
operator_selector: Any = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
from torchgen.selective_build.selector import SelectiveBuilder
|
|
||||||
|
|
||||||
from tools.autograd.gen_annotated_fn_args import gen_annotated
|
from tools.autograd.gen_annotated_fn_args import gen_annotated
|
||||||
from tools.autograd.gen_autograd import gen_autograd, gen_autograd_python
|
from tools.autograd.gen_autograd import gen_autograd, gen_autograd_python
|
||||||
|
from torchgen.selective_build.selector import SelectiveBuilder
|
||||||
|
|
||||||
# Build ATen based Variable classes
|
# Build ATen based Variable classes
|
||||||
if install_dir is None:
|
if install_dir is None:
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import unittest
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
import torchgen.model
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from tools.autograd import gen_autograd_functions, load_derivatives
|
from tools.autograd import gen_autograd_functions, load_derivatives
|
||||||
|
|
||||||
|
import torchgen.model
|
||||||
from torchgen import dest
|
from torchgen import dest
|
||||||
from torchgen.api.types import CppSignatureGroup, DispatcherSignature
|
from torchgen.api.types import CppSignatureGroup, DispatcherSignature
|
||||||
from torchgen.context import native_function_manager
|
from torchgen.context import native_function_manager
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import unittest
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
import expecttest
|
import expecttest
|
||||||
|
import yaml
|
||||||
|
|
||||||
import torchgen.dest as dest
|
import torchgen.dest as dest
|
||||||
import torchgen.gen as gen
|
import torchgen.gen as gen
|
||||||
import yaml
|
|
||||||
from torchgen.gen import LineLoader, parse_native_yaml_struct
|
from torchgen.gen import LineLoader, parse_native_yaml_struct
|
||||||
from torchgen.model import (
|
from torchgen.model import (
|
||||||
Annotation,
|
Annotation,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import unittest
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import expecttest
|
import expecttest
|
||||||
|
|
||||||
from torchgen.gen import _GLOBAL_PARSE_NATIVE_YAML_CACHE # noqa: F401
|
from torchgen.gen import _GLOBAL_PARSE_NATIVE_YAML_CACHE # noqa: F401
|
||||||
|
|
||||||
from torchgen.gen_backend_stubs import run
|
from torchgen.gen_backend_stubs import run
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
||||||
|
|
||||||
from torchgen.model import FunctionSchema
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.export._trace
|
import torch.export._trace
|
||||||
|
|
||||||
|
|
@ -16,6 +14,8 @@ from torch.export.graph_signature import (
|
||||||
from torch.fx import subgraph_rewriter
|
from torch.fx import subgraph_rewriter
|
||||||
from torch.onnx.utils import _create_jit_graph
|
from torch.onnx.utils import _create_jit_graph
|
||||||
|
|
||||||
|
from torchgen.model import FunctionSchema
|
||||||
|
|
||||||
|
|
||||||
def inplace_optimize_sym_size_div(gm: torch.fx.GraphModule):
|
def inplace_optimize_sym_size_div(gm: torch.fx.GraphModule):
|
||||||
def pattern(im, dim, scale):
|
def pattern(im, dim, scale):
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ from functools import partial
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from typing import Any, Callable, Iterable, List, Optional, Tuple, Union
|
from typing import Any, Callable, Iterable, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from torchgen.utils import dataclass_repr
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.testing import make_tensor
|
from torch.testing import make_tensor
|
||||||
from torch.testing._internal.common_device_type import (
|
from torch.testing._internal.common_device_type import (
|
||||||
|
|
@ -36,6 +34,8 @@ from torch.testing._internal.common_utils import (
|
||||||
)
|
)
|
||||||
from torch.testing._internal.opinfo import utils
|
from torch.testing._internal.opinfo import utils
|
||||||
|
|
||||||
|
from torchgen.utils import dataclass_repr
|
||||||
|
|
||||||
# Reasonable testing sizes for dimensions
|
# Reasonable testing sizes for dimensions
|
||||||
L = 20
|
L = 20
|
||||||
M = 10
|
M = 10
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user