Flip default value for mypy disallow_untyped_defs [4/11] (#127841)

See #127836 for details.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/127841
Approved by: https://github.com/oulgen
This commit is contained in:
Aaron Orenstein
2024-06-08 11:33:07 -07:00
committed by PyTorch MergeBot
parent afe15d2d2f
commit 62bcdc0ac9
128 changed files with 142 additions and 15 deletions

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from collections import defaultdict from collections import defaultdict
from copy import deepcopy from copy import deepcopy
from typing import Any, Optional, Dict, TYPE_CHECKING from typing import Any, Optional, Dict, TYPE_CHECKING

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch.ao.pruning._experimental.data_sparsifier.data_norm_sparsifier import DataNormSparsifier from torch.ao.pruning._experimental.data_sparsifier.data_norm_sparsifier import DataNormSparsifier
from torch.ao.pruning._experimental.data_scheduler.base_data_scheduler import BaseDataScheduler from torch.ao.pruning._experimental.data_scheduler.base_data_scheduler import BaseDataScheduler
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import torch.nn as nn import torch.nn as nn
from torch.ao.pruning.sparsifier.utils import module_to_fqn, fqn_to_module from torch.ao.pruning.sparsifier.utils import module_to_fqn, fqn_to_module

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Callable, Optional, Union from typing import Callable, Optional, Union
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from itertools import chain from itertools import chain
from operator import getitem from operator import getitem
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import cast from typing import cast
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch import nn from torch import nn
from torch.nn.utils.parametrize import is_parametrized from torch.nn.utils.parametrize import is_parametrized

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
""" """
Collection of conversion functions for linear / conv2d structured pruning Collection of conversion functions for linear / conv2d structured pruning
Also contains utilities for bias propagation Also contains utilities for bias propagation

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from .base_structured_sparsifier import BaseStructuredSparsifier from .base_structured_sparsifier import BaseStructuredSparsifier

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
__all__ = [ __all__ = [
"get_static_sparse_quantized_mapping", "get_static_sparse_quantized_mapping",
"get_dynamic_sparse_quantized_mapping", "get_dynamic_sparse_quantized_mapping",

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch.ao.pruning import BaseSparsifier from torch.ao.pruning import BaseSparsifier

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import warnings import warnings
from .base_scheduler import BaseScheduler from .base_scheduler import BaseScheduler

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import warnings import warnings
from .base_scheduler import BaseScheduler from .base_scheduler import BaseScheduler

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import abc import abc
import copy import copy
from collections import defaultdict from collections import defaultdict

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from . import base_sparsifier from . import base_sparsifier

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Dict, Optional, Type from typing import Any, Dict, Optional, Type
from torch.nn.utils.parametrize import type_before_parametrizations, is_parametrized from torch.nn.utils.parametrize import type_before_parametrizations, is_parametrized
from itertools import chain from itertools import chain

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from functools import reduce from functools import reduce
from typing import Callable, Optional, Tuple, Union from typing import Callable, Optional, Tuple, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
# flake8: noqa: F403 # flake8: noqa: F403
from .fake_quantize import * # noqa: F403 from .fake_quantize import * # noqa: F403

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.ao.nn.quantized as nnq import torch.ao.nn.quantized as nnq

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import copy import copy
from typing import Dict, Any from typing import Dict, Any

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.nn.parameter import Parameter from torch.nn.parameter import Parameter
from typing import List from typing import List

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import operator import operator
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import operator import operator
import torch import torch
from torch.ao.quantization.backend_config import ( from torch.ao.quantization.backend_config import (

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Type, Union, TYPE_CHECKING from typing import Any, Callable, Dict, List, Optional, Type, Union, TYPE_CHECKING

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from ._common_operator_config_utils import ( from ._common_operator_config_utils import (
_get_binary_op_configs, _get_binary_op_configs,

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.ao.nn.intrinsic as nni import torch.ao.nn.intrinsic as nni

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from .backend_config import ( from .backend_config import (
BackendConfig, BackendConfig,

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Dict, Any, List, Callable, Union, Tuple, Type from typing import Dict, Any, List, Callable, Union, Tuple, Type
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.ao.quantization.experimental.quantizer import APoTQuantizer from torch.ao.quantization.experimental.quantizer import APoTQuantizer

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Tuple from typing import Tuple
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
from typing import Any, Callable, List, Optional, Tuple, Type, Union from typing import Any, Callable, List, Optional, Tuple, Type, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
r""" r"""
This file contains utility functions to convert values This file contains utility functions to convert values
using APoT nonuniform quantization methods. using APoT nonuniform quantization methods.

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch import Tensor from torch import Tensor
from torch.ao.quantization.experimental.observer import APoTObserver from torch.ao.quantization.experimental.observer import APoTObserver

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch import Tensor from torch import Tensor
from torch.ao.quantization.experimental.quantizer import quantize_APoT, dequantize_APoT from torch.ao.quantization.experimental.quantizer import quantize_APoT, dequantize_APoT

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import numpy as np import numpy as np

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
""" """
This module implements nonuniform observers used to collect statistics about This module implements nonuniform observers used to collect statistics about
the values observed during calibration (PTQ) or training (QAT). the values observed during calibration (PTQ) or training (QAT).

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch import Tensor from torch import Tensor
import numpy as np import numpy as np

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
"""Implements modules used to perform fake quantization.""" """Implements modules used to perform fake quantization."""
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import torch.nn as nn import torch.nn as nn

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch.nn as nn import torch.nn as nn
import torch.ao.nn.intrinsic as nni import torch.ao.nn.intrinsic as nni

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import math import math
from typing import Optional, Tuple from typing import Optional, Tuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import warnings import warnings
from collections import namedtuple from collections import namedtuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.fx import map_arg, Node from torch.fx import map_arg, Node
from torch.fx.graph import Graph from torch.fx.graph import Graph

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Dict, Set, Tuple, Callable, List from typing import Any, Dict, Set, Tuple, Callable, List
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any, Dict, Set, Tuple, Callable from typing import Any, Dict, Set, Tuple, Callable
from collections import OrderedDict from collections import OrderedDict
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.ao.quantization.observer import ObserverBase from torch.ao.quantization.observer import ObserverBase

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from typing import Any, Set, Dict, List, Tuple, OrderedDict from typing import Any, Set, Dict, List, Tuple, OrderedDict
from collections import OrderedDict as OrdDict from collections import OrderedDict as OrdDict

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Tuple, Type from typing import Any, Dict, List, Optional, Tuple, Type

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch.fx import ( from torch.fx import (
GraphModule, GraphModule,
Node, Node,

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.ao.quantization.backend_config import BackendConfig from torch.ao.quantization.backend_config import BackendConfig
from torch.fx.graph import Node, Graph from torch.fx.graph import Node, Graph

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import copy import copy
from torch.fx import GraphModule from torch.fx import GraphModule

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import sys import sys
import torch import torch
from torch.fx.graph import ( from torch.fx.graph import (

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from collections import OrderedDict from collections import OrderedDict
from typing import Dict, Any from typing import Dict, Any
from torch.ao.quantization.utils import Pattern from torch.ao.quantization.utils import Pattern

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import torch import torch
import warnings import warnings

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
import re import re
from collections import defaultdict, OrderedDict from collections import defaultdict, OrderedDict

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from abc import ABC from abc import ABC
from typing import Callable, Dict, List, Optional, Type from typing import Callable, Dict, List, Optional, Type

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import torch import torch
import torch.nn as nn import torch.nn as nn

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
""" """
This module implements observers which are used to collect statistics about This module implements observers which are used to collect statistics about
the values observed during calibration (PTQ) or training (QAT). the values observed during calibration (PTQ) or training (QAT).

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import logging import logging
import operator import operator

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import types import types
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import itertools import itertools
from typing import Any, List, OrderedDict, Set, Optional, Callable from typing import Any, List, OrderedDict, Set, Optional, Callable
import operator import operator

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import logging import logging
from typing import Optional from typing import Optional

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch._subclasses import FakeTensor from torch._subclasses import FakeTensor
from torch.ao.quantization.fx.prepare import ( from torch.ao.quantization.fx.prepare import (

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import dataclasses import dataclasses
import itertools import itertools
import operator import operator

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.fx import GraphModule from torch.fx import GraphModule
from ..export_utils import _WrapperModule from ..export_utils import _WrapperModule

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import operator import operator
import types import types

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from collections import namedtuple from collections import namedtuple
from typing import Optional, Any, Union, Type from typing import Optional, Any, Union, Type
from typing_extensions import deprecated from typing_extensions import deprecated

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
from collections import OrderedDict from collections import OrderedDict
from typing import Any, Callable, Dict, Tuple, Union, List from typing import Any, Callable, Dict, Tuple, Union, List

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import itertools import itertools
import warnings import warnings

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch.ao.quantization.qconfig import QConfig from torch.ao.quantization.qconfig import QConfig

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
import copy import copy

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Callable, Dict, List, Optional, Tuple, Union from typing import Callable, Dict, List, Optional, Tuple, Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import List from typing import List
from torch.ao.quantization.pt2e.utils import _is_sym_size_node from torch.ao.quantization.pt2e.utils import _is_sym_size_node

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import copy import copy
import functools import functools
import itertools import itertools

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
import copy import copy

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import itertools import itertools
import operator import operator
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from torch import nn from torch import nn

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
""" """
Utils shared by different modes of quantization (eager/graph) Utils shared by different modes of quantization (eager/graph)
""" """

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
""" """
``torch.autograd`` provides classes and functions implementing automatic ``torch.autograd`` provides classes and functions implementing automatic
differentiation of arbitrary scalar valued functions. It requires minimal differentiation of arbitrary scalar valued functions. It requires minimal

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import operator import operator
from functools import reduce from functools import reduce
from typing_extensions import deprecated from typing_extensions import deprecated

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import operator import operator
from functools import reduce from functools import reduce

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import warnings import warnings
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import os import os
from collections import namedtuple from collections import namedtuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import functools import functools
import inspect import inspect
import itertools import itertools

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import List, Tuple from typing import List, Tuple
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import Any from typing import Any
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import collections import collections
import functools import functools
import warnings import warnings

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import abc import abc
import collections import collections
import contextlib import contextlib

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
from time import perf_counter_ns from time import perf_counter_ns

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import itertools import itertools
import warnings import warnings
from typing_extensions import deprecated from typing_extensions import deprecated

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import bisect import bisect
import itertools import itertools
import math import math

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch
from torch._C import _ImperativeEngine as ImperativeEngine from torch._C import _ImperativeEngine as ImperativeEngine

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import types import types
from contextlib import contextmanager from contextlib import contextmanager

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import hashlib import hashlib
import json import json
from typing import Dict, Tuple from typing import Dict, Tuple

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
from typing import List, Optional from typing import List, Optional
import torch import torch

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import array import array
import enum import enum
import functools import functools

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import contextlib import contextlib
from typing import Union from typing import Union

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import os import os
import sys import sys
import warnings import warnings

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch.cuda import torch.cuda
try: try:

View File

@ -1,3 +1,4 @@
# mypy: allow-untyped-defs
import torch import torch

Some files were not shown because too many files have changed in this diff Show More